Inlined comments below...
> Is there an easy way to plot multiple collections of points
> connected by a line and have only a single legend entry show
> up? It would also be nice if any modifications to that entry
> (marker, color, etc) would affect all the line segments.
Not 100% sure what you are after here. You can control which lines
and patches get passed to the legend by explicitly passing them (as
opposed to using the autolegend capabilities). Eg
ax.legend((l1, p1), ('A line, 'A patch')
Also, have you looked into the LineCollection class -- this sounds
like it would support some of what you are describing. Perhaps if you
explain a bit more.
What's happening here is that we have a plot that's a map of the earth going from -180 to 180 longitude and pole to pole. A spacecraft ground trajectory goes around and around so when it hit's the +180 longitude, it needs to wrap around to -180. We want this to be a line plot. If you just put in the x,y coordinates as a line plot, you get a long line segment when it goes from say:
(175,20) -> (-175,30)
What we've done in the past is to use a heuristic to detect this case. For example, I might say if the delta x is greater than 90% of the total longitude, it's a wrap around case. In that case, I do linear interpolation to get a point at the edge of the map (in this case 180, 25), insert this point, and split the line into two pieces at this point.
For example, if I have a data set that looks like this:
I really need this data to be drawn as two separate lines:
Ideally these two segments should be treated as a single line wherever applicable (legend, style, etc).
> Ted PS: we also need some way to draw only the n'th marker in
> a line plot. We plot a lot of trajectories where time is
> progressing along the line so it's useful to generate the
> plot using 1 minute data (for example) and then have a marker
> be displayed every 60'th point.
Look at subplot(211) in examples/subplot_demo.py. There a line is
plotted with one temporal resolution, and markers are placed along the
line at subsampled points. Basically two lines are added with
different sampling frequencies.
Does this suffice?
I'd probably label this as a "mostly acceptable work-around" since it requires generating two data arrays. In my case, the data is expensive to compute so we'd probably have to generate a second array by selectively copying points from the first array which is kind of annoying. I was hoping for a keyword that said how often to generate the markers for an existing line (with the default as one of course). Probably not a huge deal though.
Ted Drain Jet Propulsion Laboratory ted.drain@...369...
At 12:41 PM 2/11/2005, John Hunter wrote: