legend for a plot with markers every 20th data point?

Maddox Flower <maddoxflower@...273...> writes:

What fails me is how to make a legend with the appropriate 'combined'
line style '-ro'?

Make the legend first with only the line, then modify the line within
the legend:

from numpy import arange, sin
x = arange( 0., 1., 0.001 )
y = sin( 50*x )
line = plot(x, y, '-r')
markers = plot(x[::20], y[::20], 'ro')
lgd = legend([line], ['data'], numpoints=3)
lgd.get_lines()[0].set_marker('o')
draw()

···

--
Jouni K. Sepp�nen
http://www.iki.fi/jks

Jouni K. Sepp�nen wrote:

Make the legend first with only the line, then modify the line within
the legend:

from numpy import arange, sin
x = arange( 0., 1., 0.001 )
y = sin( 50*x )
line = plot(x, y, '-r')
markers = plot(x[::20], y[::20], 'ro')
lgd = legend([line], ['data'], numpoints=3)
lgd.get_lines()[0].set_marker('o')
draw()

Thanks, that's exactly what I wanted! Cheers, Maddox