many independent line segments

Hello,

I am trying to show many hundreds to a few thousand *independent* line
segments efficiently. I can of course make one call to plot() per
segment, but that is slooow and I am trying to keep up with a C
application generating the plot data.

As I read the docs for plot(), I can specify multiple points to be
connected together using array arguments, but in order to specify
multiple, independent, *disconnected* line segments in one call to plot()
I would have to use multiple sets of arguments like this:

plot(x1, y1, 'b-', x2, y2, 'r-', x3, y3, 'b-', . . .)

That is as slow as multiple calls to plot and leads to huge argument
lists.

What would be great would be the ability to specify a marker *list* that
maps to the segments, rather than just a marker string that is applied to
all segments in the list. Something like this:

plot([0, 1, 2, 3, 4], [2, 5, 7, 8, 9], ['b-', 'w-', 'b-', 'w-', 'b-'])

Then by changing the color of certain segments to the background color I
could effectively make many separate segments.

Any thoughts on the wisdom of this? Or a suggestion for doing this with
the current interface that didn't occur to me?

Rich

Hi Rich,

···

On Monday 02 May 2005 12:57 pm, Rich Drewes wrote:

Hello,

I am trying to show many hundreds to a few thousand *independent* line
segments efficiently. I can of course make one call to plot() per
segment, but that is slooow and I am trying to keep up with a C
application generating the plot data.

As I read the docs for plot(), I can specify multiple points to be
connected together using array arguments, but in order to specify
multiple, independent, *disconnected* line segments in one call to plot()
I would have to use multiple sets of arguments like this:

plot(x1, y1, 'b-', x2, y2, 'r-', x3, y3, 'b-', . . .)

That is as slow as multiple calls to plot and leads to huge argument
lists.

What would be great would be the ability to specify a marker *list* that
maps to the segments, rather than just a marker string that is applied to
all segments in the list. Something like this:

plot([0, 1, 2, 3, 4], [2, 5, 7, 8, 9], ['b-', 'w-', 'b-', 'w-', 'b-'])

Then by changing the color of certain segments to the background color I
could effectively make many separate segments.

Any thoughts on the wisdom of this? Or a suggestion for doing this with
the current interface that didn't occur to me?

What a coincidence, I just wrote an example two days ago that you might find
useful. You can find it in CVS; look for line_collection.py in the examples
directory.

--
Darren S. Dale

Bard Hall
Department of Materials Science and Engineering
Cornell University
Ithaca, NY. 14850

dd55@...163...

Beautiful, thanks! I didn't even have to upgrade my 0.80 matplotlib.

Rich

···

On Mon, 2 May 2005, Darren Dale wrote:

What a coincidence, I just wrote an example two days ago that you might find
useful. You can find it in CVS; look for line_collection.py in the examples
directory.