chombee wrote:
> My legend shows both plots as the same colour (blue) when in fact they
> are different colours. Here's the relevant code:
> 
>     font = FontProperties(size='small');
>       ...
>     b1 = bar(i,lowermeans,width,color='b')
>     b2 = bar(i+width,uppermeans,width,color='y')
>       ...    
>     legend((b1,b2),(l,u),prop=font)
> 
> I use legend exactly like this elsewhere and it works. So I can't figure
> out why in this case the legend shows both bars as blue.
> 
I managed to replicate with this example:
import numpy as N
import matplotlib.pyplot as P
lowermeans = N.arange(10)
uppermeans = lowermeans + 2
i = N.arange(0,len(lowermeans))
width = 0.4
b1 = P.bar(i,lowermeans,width,color='b')
b2 = P.bar(i+width,uppermeans,width,color='y')
P.legend((b1,b2),('lower','upper'))

Changing the legend call to this fixed it:
P.legend((b1[0],b2[0]),('lower','upper'))

It seems to work since a list of patch objects is returned by the calls
to bar, and legend seems to only use the first two objects from the
*first* list.  The question is, is it a bug, because it *is* very
unexpected behavior?

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to