a doughnut to the developer who can figure this one out for me!
If you resize the figure window slightly, the alpha channel gets
whacked on the rectangles. This only happens if the legend is added
to the axes -- comment that out and the alpha channel is fine. I
suspect we are screwing up somewhere in the way we copy properties
from legended objects to their legend proxies (ie we are reversing
this somewhere and copying properties from a proxy to the axes
The problem is in svn and probably earlier releases but I haven't tested.
from pylab import figure, show, cm, nx
from matplotlib.patches import Rectangle
fig = figure()
ax = fig.add_subplot(111, axisbelow=True)
ax.grid(True)
ax.plot([1,2,3,4,5,6,7])
ax.axvspan(1,2, facecolor='red', alpha=0.5)
ax.axvspan(3,4, facecolor='green', alpha=0.5)
red = Rectangle((0,0), 1, 1, facecolor='red', alpha=0.5)
green = Rectangle((0,0), 1, 1, facecolor='green', alpha=0.5)
# comment out next line and bug goes away!
ax.legend((red, green), ('red', 'green'), loc='best')
show()
|