Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #! /usr/bin/python3
  2.  
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. from matplotlib.patches import Rectangle
  6.  
  7. fig, axs = plt.subplots(nrows=3, figsize=(10, 5))
  8. [ax.grid(True) for ax in axs]
  9.  
  10. dx_values = [0.5, 0.2, 0.1]
  11. for idx, dx in enumerate(dx_values):
  12. for x in np.arange(0, 2*np.pi, dx):
  13. axs[idx].add_patch(Rectangle(xy=(x, 0), width=dx, height=np.sin(x), color=(1, 0, 0, 0.2)))
  14.  
  15. x = np.arange(0, 2*np.pi, 0.01)
  16. y = np.sin(x)
  17. axs[idx].plot(x, y)
  18.  
  19. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement