Reputation: 21
i wanted to to have 3d plot were the z values change every second and the change is displayed in the plot. And it works...kinda. Only the very last plot is actually shown. Before that the Figure just stays blank. I thought it had to do with my script. But then I used a working example from the rawspberry website with exactly the same result. Blank window, after script is done the last actually gets displayed. I can't find any working solution for this problem so far.
Here is the code of the example from the rwaspberry website:
import matplotlib.pyplot as plt
from time import sleep
from random import shuffle
plt.ion()
y = [i for i in range(100)]
x = [i for i in range(len(y))]
for i in range(50):
plt.clf()
plt.bar(x,y)
plt.draw()
sleep(0.5)
shuffle(y)
Upvotes: 0
Views: 258
Reputation: 647
Use plt.pause()
instead of sleep()
for i in range(50):
plt.clf()
plt.bar(x,y)
plt.draw()
plt.pause(0.5)
shuffle(y)
Upvotes: 2