On Tuesday 18 March 2008 10:50, Chris Withers wrote:
> Eric Firing wrote:
> > It sounds like what you want it the pyplot figlegend command:
> > def figlegend(handles, labels, loc, **kwargs):
> This feels like what I should be wanting except:
> - why does it need explicit parameters? why can't it pick up its lines
> and labels automatically, like legend does?

- I think this could be a good improvement, but i'm not sure if it is easy to 
expand the functionality of the axes-legend (pyplot.legend or ax.legend) to 
that of a figure-legend(pyplot.figlegend or fig.legend with fig as a figure 
instance) without missing something, because there is no axes specified and 
therefore it is not obvious which lines should be displayed. In that case the 
default behaviour might become to take all lines from all axes and that's not 
what one always needs, or isn't it?  

In this case one should do it autonomous like:

ax1 = subplot(111)
# some plotting commands
labels = []
for line in ax1.lines:
     label = line.get_label()
# or in one line: 
# labels = [line.get_label() for line in ax1.lines]
figlegend(ax1.lines, labels, 'upper right')

> - it places the legend over the top of the current chart, I want it to
> the right, so it doesn't obscure the information on the chart...

That's true and I have no idea how to overcome that (except for example 

> > or you could directly use the Figure.legend method.
> How does this differ from the normal legend command?
> How do I get hold of a figure to call its legend method?
fig.legend( ... )
and it is wrapped by 
figlegend( ... ) 
and therefore has the same functionality / arguments

and it differs from the axes-legend like explained above ...

> How does figure.legend interact with subplots?
I'm don't know, but maybe it doesn't interact with the axes / subplots at all.

> I have a bout 6 subplots on the same figure(?) and they each need to
> have a legend which is not obscuring the data plotted and isn't
> obscuring any other figure...

I think in that case the axes-legend is the preferred one, but I have no idea 
how to ensure that nothing is cover by the legend without difficult tuning of 
the parameters or at least ensure that all labels have the same widths.

best regards

This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
Matplotlib-users mailing list

Reply via email to