On 4/11/07, Maddox Flower <[EMAIL PROTECTED]> wrote: > Hi there, > > say, I have x and y data like this (the real data I am working with is > from numerical simulations, though): > > from numpy import arange, sin > x = arange( 0., 1., 0.001 ) > y = sin( 50*x ) > > Now, a line plot would not look very decent because of the 1000 > overlapping markers: > > plot(x, y, '-ro') > > Now, I'd rather have the same plot with a marker symbol only every 20th > data point. Of course, I can easily achieve this by slicing through my > data set and making two plots, one for the line and another one for the > markers: > > line = plot(x, y, '-r') > markers = plot(x[::20], y[::20], 'ro') > > Note that just doing a plot(x[::20],y[::20],'-ro') would 'distort' the > plot because the markers are being linked by straight lines. > > What fails me is how to make a legend with the appropriate 'combined' > line style '-ro'? I have tried to supply the legend statement with that > linestyle: > > legend( ['-ro'], ['data'] ) > > but it really expects a list of line instances, so that did not work.
You can create a proxy line object that you do not plot from matplotlib.lines import Line2D line = Line2D(range(10), range(10), linestyle='-', marker='o') legend((line,), (label,)) You will need to make sure that your proxy line has the same properties as the line you are trying to legend. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users