Hi All, I think I might have uncovered a bug in the legend
> code when using multiple patches so that only the first
> patch type is used in the legend.
> In [41]: matplotlib.__version__ Out[41]: '0.87.5'
> (that is revision 2782 from SVN)
> Here is some code that shows the problem:
> ------------------------------ from pylab import *
> binctrs = linspace(-4.0, 4.0, 15) vals = randn(1000) n1,
> bins1, p1 = hist(vals, binctrs, align='center') n2, bins2,
> p2 = hist(vals[:300], binctrs, align='center') setp(p1,
> 'facecolor', 'k', 'alpha', 0.2) setp(p2, 'facecolor', 'g',
> 'alpha', 0.9) legend((p1, p2), ("Frobs", "NewFrobs"))
> show() ------------------------------
The returned patches is a list of patches -- you just need to pick off
a representative one
ax = subplot(111)
binctrs = linspace(-4.0, 4.0, 15)
vals = randn(1000)
n1, bins1, p1 = hist(vals, binctrs, align='center', facecolor='black', alpha=0.2)
n2, bins2, p2 = hist(vals[:300], binctrs, align='center', facecolor='green', alpha=0.9)
legend((p1[0], p2[0]), ("Frobs", "NewFrobs"))
show()