0

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) 

1 Answer 1

2

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) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.