views:

67

answers:

1

I am doing some animated plotting and using the the matplotlib examples as a guideline. matplotlib examples

With the following linked example from that page the animation has some obvious problems when the frame is resized. What is the correct or best way to deal with this? animation_blit_wx.py
Thanks

+1  A: 

Take a look at the animation_blit_qt4.py example. You have to check the figure size manually, and if it has changed you need to draw the background again.

Heres the part which does that from the qt example, self is a Figure Canvas:

 current_size = self.ax.bbox.width, self.ax.bbox.height
    if self.old_size != current_size:
        self.old_size = current_size
        self.ax.clear()
        self.ax.grid()
        self.draw()
        self.ax_background = self.copy_from_bbox(self.ax.bbox)
tillsten
Is there some sort of resize event that can be listened for, rather than checking the size every time?
jolly swagman
you could use a resize event, if your gui framework provides one. on the other hand, it is only one if per loop, so it isn't much of a slowdown.
tillsten
matplotlib itself it is just not very fast, so if you need speed you should use another plotting library, or in case of simple line graphs do it yourself.
tillsten
I am actually finding it a bit slow. What do you recommend as an alternative?
jolly swagman