Hi:

I want to add a legend to a stem plot with two plots. The basic code is:

###########################
from pylab import *

x = [1,2,3,4,5]
y1 = [1, 2, 3, 4, 5]
y2 = [5, 4, 3, 2, 1]

subplot(211)
plot(x, y1, 'rx-')
plot(x, y2, 'bx-')
legend(('a', 'b'))

subplot(212)
stem(x, y1, 'r')
stem(x,y2, 'b')
legend(('a', 'b'))

show()
###########################

The left subplot is the same plot using plot instead of stem. You can
see the result here: http://imagebin.org/128376 .

I expect the legend for the stem case to look similar to the plot
case, however, for the stem, I get the two labels of the legend
associated with the first stem command: 'a' linked to the marker and
'b' linked to the stem line.

Is there any way to fix this? Is this a bug?

Alejandro.

------------------------------------------------------------------------------
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