I'm having trouble plotting graphs in a while loop (I get a blank figure that doesn't show any graph), what am I missing here? I provided an MWE that I run on Windows 10, Python 3. But I don't think the configuration is the problem:
import matplotlib.pyplot as plt
import time
def refresh(x,y1,y2,y3):
plt.close('all')
plt.figure()
plt.subplot(3,1,1)
plt.plot(x, y1)
plt.subplot(3,1,2)
plt.plot(x, y2)
plt.subplot(3,1,3)
plt.plot(x, y3)
plt.show
return
plt.ion
A = [1,2,3,4]
B = [15,16,8,2]
C = [8,6,4,7]
D = [5,4,3,1]
while True:
time.sleep(5)
refresh(A,B,C,D)
Another problem is it doesn't create a figure window, but displays the data after execution in the console. I would like it to create a figure window displaying the curves "refreshed" every 5 seconds.
If that is indeed a copy of your code, you need to actually call
plt.show()
Without the parentheses indicating a call of the function,
plt.show
just returns it being a function without actually being executed.