On Tue, Dec 16, 2008 at 10:09 AM, Michael Oevermann
<michael.oeverm...@tu-berlin.de> wrote:
> Hi all,
>
> I am trying to find  a solution to the following problem (without
> success so far):
> I have some high frequency data which I want to plot with a simple
> plot command using a solid line and a symbol. However, since I have many
> many
> data points I want to plot the symbol only every N'th data point. Is
> there a skip parameter
> or any other way to tell matplotlib to actually plot the symbol only
> at every N'th data point (I know it is possible in grace which I have
> stopped
> using in favour of matplotlib). Plotting the data twice- the first time
> without
> symbol showing every data point and the second time onlywith the symbol
> and some skip in the data - doesn't help as I now get two entities in
> the legend.

There is a way to do this, but it is not terribly elegant.  The tricky
part is to get the legend right::

    import numpy as np
    import matplotlib.pyplot as plt
    fig = plt.figure()
    ax = fig.add_subplot(111)

    N = 10
    x = np.arange(100.)
    y = x**2

    # the solid line, suppress auto legend
    line1, = ax.plot(x, y, linestyle='-', color='black', label='_nolegend_')
    # every N-th marker, suppress auto legend
    line2, = ax.plot(x[::N], y[::N], linestyle='', marker='o',
markerfacecolor='blue', label='_nolegend_')

    # the proxy line, both solid and markers.  Don't add it to plot, just
    # use it in legend
    import matplotlib.lines as lines
    proxyline = lines.Line2D([0,1], [0,1], linestyle='-',
color='black', marker='o', markerfacecolor='blue')

    leg = ax.legend([proxyline], ['my label'])

    plt.show()

JDH

------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to