Код:
import tkinter as tk
import numpy as np
import matplotlib.pyplot as plt
def plot_function():
angles = entry.get()
angles = angles.split(",")
angles = [angle.strip() for angle in angles]
angles = [eval(angle) for angle in angles]
x = np.linspace(0, 2*np.pi, 1000)
plt.figure()
for angle in angles:
y = np.sin(angle * x)
plt.plot(x, y, label=f"Angle: {angle}")
plt.xlabel('x')
plt.ylabel('y')
plt.title('График функции sin(angle*x)')
plt.legend()
plt.show()
root = tk.Tk()
root.title("Отрисовка графика функции")
label = tk.Label(root, text="Введите углы (разделите запятой):")
label.pack()
entry = tk.Entry(root)
entry.pack()
button = tk.Button(root, text="Отрисовать график", command=plot_function)
button.pack()
root.mainloop()