On Tue, Dec 14, 2010 at 2:29 PM, Skip Montanaro <s...@pobox.com> wrote:

> I am plotting a time series, a handful of moving averages and the
> standard deviation of one of the moving averages.  The first crop of
> data are all in an overlapping range so are plotted using the
> left-hand y axis.  The standard deviation range falls way outside the
> ranges of the other data streams, so I plot it on the right- hand
> axis.
>
> Since legends are associated with an axis how do I create one legend
> which covers all lines in the graph?  I keep getting a complaint from
> mpl about the number of labels not matching the number of arrays being
> plotted (one v. five if I get the legend associated with the
> right-hand axis, four v. five if I get the legend associated with the
> left-hand axis).
>
> Thanks,
>
> Skip Montanaro
> s...@pobox.com
>
>
>

Skip,

You can call figlegend() and build a legend for the figure, irrespectively
of any axes.  With this function, you can explicitly pass it a list of the
line objects and the labels.

http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=legend#matplotlib.pyplot.figlegend

I don't think it can automatically know about all of the lines in your graph
(then again, I haven't tried and maybe it does).

I hope this helps!
Ben Root
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to