0

I want to update multiple figures using pylab animation. I initialize a new figure for each channel to display and I set interactive mode to off using:

    pyplot.ion()
    pyplot.show()

In the class containing the figure there's a ring buffer and a method to update the data:

    def append_data(self, data):
        update buffers with data

        ...
        ...

        self.lineb.set_data(self.tbuf, self.bbuf)
        self.ax1.set_xlim( [min(self.tbuf), max(self.tbuf)] )
        self.ax1.set_ylim( [min(self.bbuf), max(self.bbuf)] )

        ...
        ...

        self.fig.show()
        pyplot.draw()

The problem: with more than one figure, only the last one updates correctly. The other ones do not refresh. I know the data is correctly added to the each figure's buffer, so the problem is not there.

Fra
  • 4,918
  • 7
  • 33
  • 50
  • avoid using `pyplot` unless you really are using it interactively. `fig.canvas.draw()` will do the same thing for a specific figure. – tacaswell Feb 01 '14 at 00:24
  • I'm not sure I understand your suggestion. do you mean avoid using `pyplot`command or module? what would you use instead? – Fra Feb 02 '14 at 07:55
  • It looks like you are embedding, the event loop of `pyplot` can conflict with the event loop of the your gui. – tacaswell Feb 02 '14 at 20:24

1 Answers1

0

I found a solution following this article.

I initialized the figure with a name:

fig = pyplot.figure(name)

and then I changed the lines:

    self.fig.show()
    pyplot.draw()

to:

    pyplot.figure(name)
    pyplot.draw()

Apparently this works, not completely sure why.

Community
  • 1
  • 1
Fra
  • 4,918
  • 7
  • 33
  • 50