1

I'm basically trying to create a configurable number of figures and a configurable number of subplots on each figure. And then go retrieve data once a minute or so and update those plots.

If I do plot.show() the plot comes up and seems to wait for the figures to be close before executing any other lines of code. So I can't just tell it to wait a minute and replot.

If I go with the fig.show() it comes up and closes too quickly.

So I'm at a loss for how to do this properly where I have a plot that stays open for a minute or so (would like to also configure) and then updates. And it needs to be done for a configurable number of figures and subplots.

I've been working in pyplot and keep trying to define a 2-d array of line objects. But I think I'm going about this the wrong way since all I really want to do is replot data every minute or so.

Here are more details of what I'm working on:

1) I have zip files filled with xml data that gets updated in real time (once a minute the xml data is added to the zip file for that day 2) I want to find certain xml data and write only new data to a sqlite DB 3) Find data in the sqlite DB and make a plot of it. 4) The number of figures needs to be configurable (1 or 2 at the moment but perhaps more in the future) and the number of subplots on each figure should also be configurable. 5) In real-time, find the new data and replot or animate it.

1 - 4 are completely done and I can plot the data for designated periods of time... just not replot it.

Hope this made sense. Thanks in advance.

Jesse Reich
  • 87
  • 1
  • 1
  • 11

1 Answers1

2

Your design is getting stuck because you are trying to do 2 tasks in 1 thread: showing a GUI, and updating the background data for it. A GUI in python takes an entire thread to run itself, which is why your program stops, or "blocks" continuing on when you call this function. What you need to do is use matplotlib's "non-blocking" features to allow your program to update. This similar Stack Overflow question offers several answers explaining how to use the concept of a non-blocking plot.

Community
  • 1
  • 1
FrisbeeGirl
  • 181
  • 3