draw after set_data

Hi,

I use qt4 backend.
I update some lines doing something like that:

   def draw_curves(self, datas, x):
       for y in datas:
           self.lines[i].set_data(x, y)
           min_y, max_y = self.min_max(y)
           self.ax[i].axis((0, x[-1], min_y, max_y))
           #self.ax[i].draw_artist(self.lines[i])
           #self.fig.canvas.blit(self.ax[i].bbox)
       self.fig.canvas.draw()

the self.fig.canvas.draw() is very slow. (I have 20 subplot in that figure).
I tried to use:
           self.ax[i].draw_artist(self.lines[i])
           self.fig.canvas.blit(self.ax[i].bbox)
it's very fast. But it does not update the scale of the plot.
and it does not remove the old datas.

Can someone help me on that ?
if I plot a sin(x) at first, I get it between 0 and 1. then, if I plot
2.sin(x), it does not update the zoom to 0-2

thank you,
Philippe

hi,

sorry to bring this up again.
style haven't found how to draw my plot faster than
self.fig.canvas.draw(), after a set_data()

thanks

2010/9/1 Philippe Crave <philippe.crave@...287...>:

···

Hi,

I use qt4 backend.
I update some lines doing something like that:

def draw_curves(self, datas, x):
for y in datas:
self.lines[i].set_data(x, y)
min_y, max_y = self.min_max(y)
self.ax[i].axis((0, x[-1], min_y, max_y))
#self.ax[i].draw_artist(self.lines[i])
#self.fig.canvas.blit(self.ax[i].bbox)
self.fig.canvas.draw()

the self.fig.canvas.draw() is very slow. (I have 20 subplot in that figure).
I tried to use:
self.ax[i].draw_artist(self.lines[i])
self.fig.canvas.blit(self.ax[i].bbox)
it's very fast. But it does not update the scale of the plot.
and it does not remove the old datas.

Can someone help me on that ?
if I plot a sin(x) at first, I get it between 0 and 1. then, if I plot
2.sin(x), it does not update the zoom to 0-2

thank you,
Philippe

hi,

sorry to bring this up again.
style haven't found how to draw my plot faster than
self.fig.canvas.draw(), after a set_data()

If you need to change the scale of the plot when you update the data, then I don't see any alternative to redoing the whole plot. If that is too slow, then mpl may simply be the wrong tool for the job. Parts of mpl have been nicely optimized for speed, but generating a large number of subplots is not among them. I don't expect this will change any time soon. The tick generation and labeling is the main time sink. If I generate 20 blank subplots, with default ticks and labels, each draw takes 420 ms on my machine. If I set all the ticks to the empty list, it drops to 34 ms.

Eric

···

On 09/07/2010 07:33 PM, Philippe Crave wrote:

thanks

2010/9/1 Philippe Crave<philippe.crave@...287...>:

Hi,

I use qt4 backend.
I update some lines doing something like that:

   def draw_curves(self, datas, x):
       for y in datas:
           self.lines[i].set_data(x, y)
           min_y, max_y = self.min_max(y)
           self.ax[i].axis((0, x[-1], min_y, max_y))
           #self.ax[i].draw_artist(self.lines[i])
           #self.fig.canvas.blit(self.ax[i].bbox)
       self.fig.canvas.draw()

the self.fig.canvas.draw() is very slow. (I have 20 subplot in that figure).
I tried to use:
           self.ax[i].draw_artist(self.lines[i])
           self.fig.canvas.blit(self.ax[i].bbox)
it's very fast. But it does not update the scale of the plot.
and it does not remove the old datas.

Can someone help me on that ?
if I plot a sin(x) at first, I get it between 0 and 1. then, if I plot
2.sin(x), it does not update the zoom to 0-2

thank you,
Philippe

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users