How do I delete or close a graph?
I had defined a function to plot a graph. However, whenever I change the variable and close the matplotlib window and draw a new graph, the previous graph is not deleted. Below is my program:
def graphforcevsmass():
global velocityvalue
global radiusvalue
for i in range(101):
j = i * float(int(velocityvalue) ** 2 / int(radiusvalue))
x.append(i)
y.append(j)
plt.plot(x, y)
plt.draw()
In my program, I used a button to activate the function above and the variable will change depending on the scale in the tkinter window. (I am coding python in enthought canopy using tkinter and matplotlib module)