Advertisement
Socialking

Untitled

Mar 30th, 2021
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3.  
  4. ### Zadanie 1
  5. x = np.arange(0, 30, 1)
  6. y = x ** 2 + x
  7.  
  8. ### Zadanie 2
  9. plt.scatter(x, y)
  10. plt.show()
  11.  
  12. ### Zadanie 3
  13. plt.suptitle('Wykresy')
  14. plt.subplot(2, 1, 1)
  15. plt.plot(x, y, marker='o', linestyle='-')
  16. plt.title('Wykres funkcji x^2 + x')
  17. y = x ** 3 + x
  18. plt.subplot(2, 1, 2)
  19. plt.plot(x, y, 's--', color='red')
  20. plt.title('Wykres funkcji x^3 + x')
  21. plt.show()
  22.  
  23. ### Zadanie 4 + Zadanie 5
  24. plt.style.use('seaborn')
  25. plt.suptitle('Wykresy')
  26. plt.legend(loc='best')
  27. plt.subplot(2, 1, 1)
  28. plt.plot(x, y, marker='o', linestyle='-')
  29. plt.title('Wykres funkcji x^2 + x')
  30. y = x ** 3 + x
  31. plt.subplot(2, 1, 2)
  32. plt.plot(x, y, 's--', color='red')
  33. plt.legend(loc='best')
  34. plt.title('Wykres funkcji x^3 + x')
  35. plt.show()
  36.  
  37. ## Zadanie 6
  38. def circle_points(r, n):
  39.     circles = []
  40.     for r, n in zip(r, n):
  41.         t = np.linspace(0, 2*np.pi, n, endpoint=False)
  42.         x = r * np.cos(t)
  43.         y = r * np.sin(t)
  44.         circles.append(np.c_[x, y])
  45.     return circles
  46.  
  47. r = [0.6]
  48. n = [36]
  49. circles = circle_points(r, n)
  50.  
  51. fig, ax = plt.subplots()
  52. for circle in circles:
  53.     ax.scatter(circle[:, 0], circle[:, 1])
  54. ax.set_aspect('equal')
  55. plt.show()
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement