fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. # Визначення діапазону значень x
  5. x = np.linspace(-10, 10, 400)
  6.  
  7. # Визначення функцій
  8. y1 = np.sin(x)
  9. y2 = np.cos(x)
  10. y3 = x ** 2
  11. y4 = np.exp(-x**2)
  12.  
  13. # Побудова графіків
  14. plt.figure(figsize=(10, 6)) # Розмір графіка
  15.  
  16. plt.plot(x, y1, label='sin(x)', color='blue')
  17. plt.plot(x, y2, label='cos(x)', color='green')
  18. plt.plot(x, y3, label='x^2', color='red')
  19. plt.plot(x, y4, label='exp(-x^2)', color='purple')
  20.  
  21. # Налаштування графіка
  22. plt.title('Графіки функцій')
  23. plt.xlabel('x')
  24. plt.ylabel('y')
  25. plt.grid(True)
  26. plt.legend()
  27. plt.axhline(0, color='black', linewidth=0.5) # x-axis
  28. plt.axvline(0, color='black', linewidth=0.5) # y-axis
  29.  
  30. # Показати графік
  31. plt.show()
  32.  
Success #stdin #stdout #stderr 3.44s 69556KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Fontconfig error: No writable cache directories