Line Graph generator

This is a little project that took me a couple of hours to build. In short, it generates a line graph based on the formula you enter, where time is t. This project will only work when copied into a python file as repl.it doesn’t function well with turtle.

from math import *
import time
import turtle
tu=turtle.Turtle()
text=turtle.Turtle()
text.color("Red")
text.speed="fastest"
text.ht()
text.pu()
t=0
zoom=input('Zoom ')
fx=input('x= ')
fy=input('y= ')
presc=1/float(zoom)
def get(x,y):
    print(x/zoom,y/zoom)
    text.clear()
    text.goto(x,y)
    text.write("("+str(x/zoom)+","+str(y/zoom)+")")
if zoom=='':
    zoom=1
zoom=float(zoom)
turtle.title("My Python Graph")
tu.pensize(zoom)
turtle.onscreenclick(get)
tu.ht()
tu.pd()
while True:
    t+=presc
    t+=float(presc)
    fx=fx.replace(' ','')
    fx=fx.replace('y','fy')
    fy=fy.replace(' ','')
    fy=fy.replace('x','fx')
    tu.goto(eval(str(fx))zoom,eval(str(fy))zoom)
    time.sleep(0)

Leave a Reply

Your email address will not be published. Required fields are marked *