Line collections vs a collection of lines

I'm trying to figure out the best way to handle the following situation:
I have a wxApp that embeds a matplotlib figure in a panel. I use custom
code to control adding and removing series from the axes in this figure,
with some pretty fine grained control on when things get drawn, zoomed,
etc. To be clear, I'm not using pylab here, I'm coding directly into
matplotlib.

Anyhow, I now have the case where I want to be plotting a modest number
of series (say 100) with a reasonably large density (say >1000 pts).
These series will all have the same or similar styles (thickness,
colour, etc) and will definitely have the same length.

In context of my current app, I could achieve this simply by calling my
.addSeries routine multiple times. Or, I could use a Line Collection to
handle them en masse.

The thing is, after taking a quick read through of the source code, I'm
not certain that I'm gaining anything by using a line collection in this
case.

I did a quick comparison using the line_collection.py example, and even
using pylab there didn't seem to be any performance hit to doing:

lines = [zip(x,y) for y in ys]
for series in x:
  plot(lines[series])

Instead of using:

line_segments = ...
ax.add_collection(line_segments)

Can anyone give me advice if I should code targeting collections or to
just use my current single-series code?

Thanks,
Anthony.

···

--
Anthony Floyd, PhD
Convergent Manufacturing Technologies Inc.
6190 Agronomy Rd, Suite 403
Vancouver BC V6T 1Z3
CANADA

Email: Anthony.Floyd@...1616... | Tel: 604-822-9682
WWW: http://www.convergent.ca | Fax: 604-822-9659

CMT is hiring: See http://www.convergent.ca for details

Anthony,

When I do a quick test of line_collection.py versus a modification that makes individual plot calls, with the results written to a png file, I get about 1.05 s with the collection and 1.2 s with the lines. But a trivial plot still takes 0.52 seconds, so if you subtract out this general startup overhead the improvement with the line collection is about 30%.

It probably comes down to program simplicity and readability, not speed, in your case.

Eric

Anthony M. Floyd wrote:

···

I'm trying to figure out the best way to handle the following situation:
I have a wxApp that embeds a matplotlib figure in a panel. I use custom
code to control adding and removing series from the axes in this figure,
with some pretty fine grained control on when things get drawn, zoomed,
etc. To be clear, I'm not using pylab here, I'm coding directly into
matplotlib.

Anyhow, I now have the case where I want to be plotting a modest number
of series (say 100) with a reasonably large density (say >1000 pts).
These series will all have the same or similar styles (thickness,
colour, etc) and will definitely have the same length.

In context of my current app, I could achieve this simply by calling my
.addSeries routine multiple times. Or, I could use a Line Collection to
handle them en masse.

The thing is, after taking a quick read through of the source code, I'm
not certain that I'm gaining anything by using a line collection in this
case.

I did a quick comparison using the line_collection.py example, and even
using pylab there didn't seem to be any performance hit to doing:

lines = [zip(x,y) for y in ys]
for series in x:
  plot(lines[series])

Instead of using:

line_segments = ...
ax.add_collection(line_segments)

Can anyone give me advice if I should code targeting collections or to
just use my current single-series code?

Thanks,
Anthony.

--
Anthony Floyd, PhD
Convergent Manufacturing Technologies Inc.
6190 Agronomy Rd, Suite 403
Vancouver BC V6T 1Z3
CANADA

Email: Anthony.Floyd@...1616... | Tel: 604-822-9682
WWW: http://www.convergent.ca | Fax: 604-822-9659

CMT is hiring: See http://www.convergent.ca for details

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users