Advertisement
mikhail_dvorkin

PyPlot example

Mar 17th, 2016
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. plt.figure(figsize=(6, 6))
  5. x = np.linspace(-np.pi, np.pi)
  6. y = np.sin(x)
  7. z = np.cos(x)
  8. plt.plot(x, y, "o", color="orange", label="sin")
  9. plt.plot(x, z, "v", label="cos")
  10. plt.xlim(-np.pi, np.pi)
  11. plt.xticks([-np.pi/2, 0, np.pi/2], [r"$-\frac{\pi}{2}$", "$x^2$", r"$\frac{\pi}{2}$"])
  12. plt.ylim(-np.pi, np.pi)
  13. plt.scatter(1, 1, color="red")
  14. plt.scatter([1, 1.1, 1.2], [1.2, 1.1, 1], color="orange")
  15. plt.annotate("max of sin", xy=(x[np.argmax(y)], np.max(y)))
  16. plt.legend(loc="upper left")
  17. #plt.plot(x, y, linestyle="-")
  18. a = np.random.random_sample(10)
  19. b = np.random.random_sample(10)
  20. #plt.plot(a, b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement