| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛

turtle制图，出现杂乱的线条

import turtle

def drawPicture(list1,list2):

printer = turtle.Turtle()

maxN = max(list2)

n = 0
while n<12:
if n ==0:

turtle.penup()
turtle.goto(-300,-300)
turtle.penup()
else:
turtle.pendown()
turtle.goto(list1[n]*7-300,600/maxN*list2[n]-300)
n += 1

m = 0
while m < 12:

#坐标轴 横线
turtle.penup()
turtle.goto(-300,-300)
turtle.pendown()
turtle.goto(300,-300)

#坐标轴竖线
turtle.penup()
turtle.goto((list1[m])*600/80-300,-300)
turtle.pendown()
turtle.goto((list1[m])*600/80-300,-280)

#        #坐标轴  数值

turtle.tracer(False)
printer.hideturtle()
turtle.penup()
printer.goto((list1[m])*600/80-300,300)

printer.write(list1[m])
turtle.penup()

#        #坐标轴  数值

turtle.tracer(False)
printer.hideturtle()
turtle.penup()
printer.goto((list1[m])*600/80-300,200)

printer.write(list1[m])
turtle.penup()
#        #坐标轴  数值

turtle.tracer(False)
printer.hideturtle()
turtle.penup()
printer.goto((list1[m])*600/80-300,100)

printer.write(list1[m])
turtle.penup()
#        #坐标轴  数值

turtle.tracer(False)
printer.hideturtle()
turtle.penup()
printer.goto((list1[m])*600/80-300,-320) ##执行这一部分代码就会出现杂乱的线条？，去掉就ok，怎么回事？？？？？

printer.write(list1[m])
turtle.penup()

m += 1

turtle.done()

x = [1.85,2.5,3.5,4.5,5.5,7,9,12.5,17.5,25,45,80]
y = [0.0668597298294577,0.190783403086985,0.625858126547849,
0.928003660230551,0.12093088417922,0.0803298850859823,
0.434187250956755,0.175729376794082,0.0913547218146808,
0.0642969332037823,0.0417594398418328,0.0218716849258358]

drawPicture(x,y)

turtle.penup() 改为 printer.penup()

• 4
• 1/1页
• 1