xy = []
for x in range(980):
xy.append((x+10) * x_increment)
xy.append(int(math.sin(x * x_factor) * y_amplitude) + center)
sin_line = canv.create_line(xy, fill='blue')]
Вот код целиком…
from tkinter import * import math root = Tk() root.title("Simple plot using canvas and line") root.geometry('1000x600') canv = Canvas(root, width = 1000, height = 600, bg = "#002") for x in range(25): k = 44.5 * x canv.create_line(10+k, 590, 10+k, 10, width=0.3, fill='#191938') canv.create_line(10, 10+k, 990, 10+k, width=0.3, fill='#191938') canv.create_line(10,10,10,600, width=1, arrow=FIRST, fill='white') canv.create_line(0,590,990,590, width=1,arrow=LAST, fill='white') canv.create_line(10,590,990,10, width=1, fill='red') height = 600 center = height / 2 x_increment = 1 x_factor = 0.02 y_amplitude = 200 xy = [] for x in range(980): xy.append((x+10) * x_increment) xy.append(int(math.sin(x * x_factor) * y_amplitude) + center) sin_line = canv.create_line(xy, fill='blue') canv.pack() root.mainloop()