Use interactive mode and single window.

master
LEdoian 9 months ago
parent f8fd60b706
commit fda2cd05b0

@ -41,6 +41,10 @@ def main():
print("New time series.")
ts = TimeSeries(states=set(), jobstates=set(), data=dict())
plt.ion()
plt.clf()
plt.show(block=False)
while True:
time, states, jobstates = get_data()
print(f'data got at {time}')
@ -56,8 +60,6 @@ def main():
print('pickle saved')
# Show the plot
plt.close()
plt.clf()
x = sorted(ts.data.keys()) # times
states = sorted(ts.states)
ys = [tuple(ts.data[time][0].get(state, 0) for state in states) for time in x] # numbers per state
@ -67,7 +69,6 @@ def main():
plt.stackplot(x, ys, labels=states)
plt.legend(loc='upper left')
print('showing plot')
plt.show(block=False)
plt.pause(poll_rate)

Loading…
Cancel
Save