标题:turtle制图,出现杂乱的线条
取消只看楼主
frefly0203
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2021-1-9
结帖率:0
已结贴  问题点数:20 回复次数:1 
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)
搜索更多相关主题的帖子: False 出现 goto 代码 坐标轴 
2021-01-09 22:26
frefly0203
Rank: 1
等 级:新手上路
帖 子:22
专家分:0
注 册:2021-1-9
得分:0 
太感谢啦
2021-01-11 20:45



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-504587-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.079514 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved