Skip to content Skip to sidebar Skip to footer

How To Undraw Plot With Zelle Graphics?

This is a code problem for Python 3.5.2 using John Zelle's graphics.py: I have spent a good amount of time looking for the answer here, but just can not figure it out. The function

Solution 1:

The first issue is that undraw() is a method of GraphicsObject, not GraphWin, so win.undraw() is simply incorrect.

The second issue is that plot() is a low level pixel setting method that does not keep track of what it did at the Zelle Graphics level, unlike objects that are drawn.

However, the underpinning is Tkinter which does keep track of objects that it draws, and GraphWin is a subclass of Canvas, so you can do:

win = GraphWin("Plot", 500, 500) # Creates a windowfor m inrange(j):  # Loop for each function
    color = random.choice(['red', 'black', 'green', 'yellow', 'pink', 'blue']) # Randomizes a color for each functionfor h inrange(t):  # Loop for each pair of values "x, y"
        win.plot(axis[h], points[m][h], color) # Find points and plot each point in win
    win.getMouse()  # Pause before clicking
    win.delete("all")  # Clear out old plot

Post a Comment for "How To Undraw Plot With Zelle Graphics?"