turtle制图,出现杂乱的线条
大家好,我用turtle制图,如果加入68到74行的代码,就会出现杂乱的线条,如果没有这部分代码就没问题,请问这是怎么回事。我是初学者,请多多帮忙,谢谢。我用的是pycharm-2.5.2和python-3.8.1。
以下是代码:
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)