n Tue, Jul 28, 2009 at 8:11 AM, Roland Koebler <r.koeb...@yahoo.de> wrote:

> Hi,
>
> I've got some performance problems with matplotlib, and would like to
> ask if you know any way I can make it faster.
>
> If there is no such way, I have to decide to (a) either enhance matplotlib
> or (b) write my own plotting-library.
> (I'm currently using matplotlib to plot data "live" on the screen,
> including
> animation, scrolling, zoom+pam, custom scales (to zoom out some part of the
> plot), and multiple X-/Y-Axes. I therefore already wrote some wrappers
> around
> matplotlib to implement some of these features.)
>
> In detail:
> - I have a figure containing some plots (lines).
> - About every second I "update" the plot:
>  - Add a few points to the lines.
>    (=add point to an array and call set_data(array))
>  - Scroll the plot, so that the latest point is on the right of the plot.
>    Older points disappear on the left side of the plot.
>    (=set_xaxis() + draw())
> - I'm using GtkAgg, incl. animation, (re)storing the background, drawing
>  the artists and blit.
>  (canvas.restore_region(...), ax.draw_artist(...), canvas.blit(bbox))
>
> This works as long as the plot only contains a few points,
> although 2 figures + 5-10 lines per figure and an update every 0.5 s
> already consumes about 10-20% CPU (on a 1.4 GHz Pentium).
> By the way: Is this speed normal, or is matplotlib usually faster?
>
> But as soon as the plot contains *many* points (several 10000 up to
> several 100000), the plotting becomes terribly slow -- up to 30s
> per update and more!
>
> Do you know any way to make this faster?
>
> My ideas are:
> - Since I only add points to the *right* of the lines, I could reduce the
>  number of points, by first removing all points which are outside of
>  the current visible plotting-window from my array, and then calling
>  set_data() with the reduced array.
> - This unfortunately wouldn't reduce the number of points in very dense
>  plots. It would be possible to (a) replace several points which all
>  result in the same plotted point by a single point or (b) cache the
>  plotted points e.g. on pixel-level. I think (b) would probably require
>  to write a new backend.


There might be some performance improvement to be had depending on how you
are adding the additional points to the array.  Seeing a complete, minimal
of the code showing the performance problem would be needed, since it's the
details that matter in this case.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
Sent from Norman, Oklahoma, United States
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to