Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我需要用python turtle绘制一个图,要绘制100000个点_Python_Python 3.x_Turtle Graphics - Fatal编程技术网

我需要用python turtle绘制一个图,要绘制100000个点

我需要用python turtle绘制一个图,要绘制100000个点,python,python-3.x,turtle-graphics,Python,Python 3.x,Turtle Graphics,我必须画一个10万点的python龟线图。我不需要x轴或y轴上的任何数字。所有y轴位置都在一个名为C_txt_列表的列表中。到目前为止,我已经有一些代码可以打印C_txt_列表中的每个值。C_txt_列表仅为0到100之间的值 # re-opens Rand_Numbers but the complete version and in read mode C_txt = open("Rand_Numbers", "r") # reads each line of C_txt and add

我必须画一个10万点的python龟线图。我不需要x轴或y轴上的任何数字。所有y轴位置都在一个名为C_txt_列表的列表中。到目前为止,我已经有一些代码可以打印C_txt_列表中的每个值。C_txt_列表仅为0到100之间的值

# re-opens Rand_Numbers but the complete version and in read mode

C_txt = open("Rand_Numbers", "r")

# reads each line of C_txt and adds it to a list

with C_txt as File:

    C_txt_list = C_txt.readlines()

C_txt_list = [lines.strip() for lines in C_txt_list]

# prints each element in C_txt_list

index_Num = 0

while index_Num != repeats:

    print(C_txt_list[index_Num])

    index_Num += 1
我还需要一个1500便士乘800便士的窗口。谢谢你的帮助

turtle.screensize(canvwidth=None, canvheight=None, bg=None)

turtle.screensize(1500,800) //for your issue.

下面是一个粗略的例子,它应该符合您的描述:

from turtle import Screen, Turtle

screen = Screen()
screen.setup(1500, 800)
screen.screensize(100_000, 800)
screen.tracer(False)

turtle = Turtle()
turtle.hideturtle()
turtle.penup()

with open("Rand_Numbers") as file:
    for x, line in enumerate(file, start=-50_000):
        y = int(line)  # int() deals with the whitespace/newline

        turtle.goto(x, y)
        turtle.pendown()  # needed after 1st point

screen.tracer(True)
screen.exitonclick()

注意窗口底部的滚动条,以查看我编写此代码生成的其余“数据”:

from random import randint

with open("Rand_Numbers", 'w') as file:
    for x in range(100_000):
        y = randint(0, 100)
        print(y, file=file)
旁白

这个问题在Python turtle中出现了一个恼人的小故障。我想枚举从0开始的数据,而不是从-50000开始,因此我尝试修改坐标系以匹配数据:

screen.setup(1500, 800)
screen.setworldcoordinates(0, -400, 1500, 400)
screen.screensize(100_000, 800)

但是,通过它们的实现,
screensize()
撤消了
setworldcordinates()
的工作,
setworldcordinates()
撤消了
screensize()
的工作。所以不管你叫他们什么顺序,这都不行

这不是一个答案,这并没有很大帮助,因为我知道如何使用海龟,但我只是不确定这一点。一个更具体的链接是:这个答案是不正确的,因为
screensize()
影响可滚动的背景画布,而不是屏幕上窗口的大小,因此不是OP指定的内容。