Python Tkinter画正弦曲线
标签:
杂谈 |
分类: Python |
from Tkinter import *
from math
import *
canvas = Canvas(width=525,height=300,bg="white")
canvas.pack(expand=YES,fill=BOTH)
x1 = 0
y1 = 150
for x in range(0,500):
y =
sin(x*2*pi/500)*50
canvas.create_line(x1,y1,x,150-y,fill =
'red')
x1 =
x;
y1 =
150-y;
canvas.create_line(0,150,525,150,dash = (4,4)) #x轴
canvas.create_line(250,0,250,300,dash = (4,4)) #y轴
mainloop()
代码执行结果
http://s9/mw690/001ZUppKzy7h2GwbJ5C78&690Tkinter画正弦曲线" TITLE="PythonTkinter画正弦曲线" />
from math
canvas = Canvas(width=525,height=300,bg="white")
canvas.pack(expand=YES,fill=BOTH)
x1 = 0
y1 = 150
for x in range(0,500):
canvas.create_line(0,150,525,150,dash = (4,4)) #x轴
canvas.create_line(250,0,250,300,dash = (4,4)) #y轴
mainloop()
代码执行结果
http://s9/mw690/001ZUppKzy7h2GwbJ5C78&690Tkinter画正弦曲线" TITLE="Python

加载中…