I have a plot using matplotlib which updates every second. It's intended only for slow monitoring so I followed a simple approach of clearing and drawing again and again which is not optimum but I wanted simplicity.
my_fig = plt.figure()
ax1 = plt.subplot(111)
plt.show(block=False)
while True:
data = read_data_and_process(...)
ax1.plot_date(data[0], data[1], '-')
my_fig.autofmt_xdate()
plt.draw()
time.sleep(1)
ax1.cla()
It works but if I resize the window, the plot doesn't change its size. If I plot the data without updating, I can resize the window and the plot resizes accordingly:
my_fig = plt.figure()
ax1 = plt.subplot(111)
data = read_data_and_process(...)
ax1.plot_date(data[0], data[1], '-')
my_fig.autofmt_xdate()
plt.show(block=True)
How can I do to be able to resize the window on the first example while updating the data?
Thanks!