Código
[/size][/size][/size]
def graficar_funciones2D(*args): """ El primer vector se tomara como las coordenadas de inicio de la gráfica si no las proporcionas por defecto es (0, 0). """ # ----------- Workspace -------------- WIDTH = 700 HEIGHT = 500 wn = Screen() wn.title("Vectores y gráficas básicas") wn.setup(WIDTH, HEIGHT) wn.screensize(WIDTH-10, HEIGHT-10) wn.bgcolor("#FFFDF9") pen = Turtle() pen.pen({"pensize": 2, "shown": False, "speed": -1}) # ----------- global variables -------------- dot_radio = 5 color = "red" wn_width = wn.window_width() wn_height = wn.window_height() """ # Descomenta esto si quieres ver un fondo cuadriculádo # ----------- grid -------------- pen.pu() pen.goto(-wn_width, wn_height) pen.seth(0) pen.pd() for i in range(0, wn_height+wn_height, 10): pen.pencolor("#daafaf") pen.pensize(1) pen.fd(wn_width) pen.up() pen.goto(-wn_width, (wn_height)-i) pen.down() pen.fd(wn_width) pen.pu() pen.goto(-wn_width, wn_height) pen.seth(270) pen.pd() for j in range(0, wn_width+wn_width, 10): pen.fd(wn_height) pen.up() pen.goto(-wn_width+j, wn_height) pen.down() pen.fd(wn_height) """ # ----------- Graph -------------- pen.up() pen.home() pen.pencolor("#090909") pen.pd() for i in range(4): pen.fd(wn_width) pen.bk(wn_width) pen.lt(90) # ----------- Points -------------- vector = args pen.up() pen.goto(vector[0][0], vector[0][1]) pen.pd() for values in vector: # pen.up() # Descomenta esta linea si no deseas ver el trazo del dibujo pen.goto(values[0], values[1]) # pen.pd() # Descomenta esta linea si no deseas ver el trazo del dibujo pen.dot(dot_radio, color) # pen.write(tuple(values), False, "right", ("tahoma", 7, "italic")) wn.listen() wn.onkeypress(lambda: wn.bye(), "space") wn.mainloop()