Sorry, I notice that there may be need for an additional explanation:

What I call "explicit label" is one that is given as kwarg to the plot
command like

    plot(x,sin(x),label="sin(x)")

My standard use of legends is to give such an explicit label to every
significant line and call legend() without arguments at the end. This
approach is much more comfortable than using arguments to legend itself,
as you do not need to keep track of handles and labels with every change
that you make in the plotting script.

Greetings,
Norbert



Norbert Nemec wrote:
> This is the result of a change that I committed in between 0.90.0 and
> 0.90.1 - sorry if it caused confusion...
>
> The idea is exactly what you observed: legend() only displays those
> lines that have an explicit label set.
>
> If a certain line in a figure does not have a label, I think it is
> rather pointless displaying it in a legend at all. I mean - the legend
> is meant to explain the individual lines and the default labels like
> "line0" can hardly be counted as "explanation".
>
> Maybe, though, there should be one additional condition:
> * If no lines or patchsets have explicit labels, display all defaults.
> * If any line or patch has an explicit label, display only the explicit
> labels.
>
> This would probably avoid confusion about a completely empty legend.
> What do you think?
>
> Greetings,
> Norbert
>
>
>
>
> Jonathan Griffitts wrote:
>   
>> In matplotlib 0.90.1 the behavior of legend() seems to have changed.
>>
>> Here's a test code fragment:
>> ---------------------------
>> import pylab
>> import numpy
>>
>> y=numpy.arange(-10,10)**2
>> print y
>> pylab.plot(y)
>> pylab.legend()
>> pylab.show()
>> ---------------------------
>> Running on python 2.5.1, matplotlib 0.90.0 gives me a reasonable-looking
>> legend in upper right corner with label "line0".
>>
>> matplotlib 0.90.1 gives an empty rectangular box, fairly large, right in
>> the middle of the plot.
>>
>> Attempting to move the legend with loc=2 or whatever has no effect.
>> However, giving an explicit label ( pylab.legend(['line1']) ) makes it
>> start working the same as 0.90.0.
>>
>> I started looking at the source but don't have time today to understand
>> how this is supposed to work.  Maybe later.
>>
>>
>>
>> Is this the intended behavior?  The announcement for 0.90.1 says:
>> "Display only meaningful labels when calling legend() without args."
>> It's not clear to me what this means.
>>
>>   
>>     
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to