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()
"John Hunter" <jd...@gm...> writes: > 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 Here's at least a clue: change your alphas from 0.5 to 0.1. Then resize the window several times and watch the rectangles become a little bit darker each time. I suspect that extra copies of the rectangles are being created. -- Jouni K. Seppänen http://www.iki.fi/jks
I committed the following change, which seems to fix the bug. Index: legend.py =================================================================== --- legend.py (revision 3031) +++ legend.py (working copy) @@ -315,7 +315,7 @@ raise Exception, 'Auto legends not available for figure legends.' def get_handles(ax): - handles = ax.lines + handles = ax.lines[:] handles.extend(ax.patches) handles.extend([c for c in ax.collections if isinstance(c, LineCollection)]) -- Jouni K. Seppänen http://www.iki.fi/jks
On 3/1/07, Jouni K. Sepp=E4nen <jk...@ik...> wrote: > I committed the following change, which seems to fix the bug. > - handles =3D ax.lines > + handles =3D ax.lines[:] Wow, nasty and subtle. Good work! Now how do I get a doughnut to you in Finland :-) Any ideas Perry? JDH
On Mar 1, 2007, at 10:15 AM, John Hunter wrote: > On 3/1/07, Jouni K. Sepp=E4nen <jk...@ik...> wrote: >> I committed the following change, which seems to fix the bug. > >> - handles =3D ax.lines >> + handles =3D ax.lines[:] > > Wow, nasty and subtle. Good work! Now how do I get a doughnut to you > in Finland :-) Any ideas Perry? What, you didn't like the way I did it? ;-)=
On 3/1/07, Perry Greenfield <pe...@st...> wrote: > What, you didn't like the way I did it? ;-) Actually, I think I saved that in the freezer still in the envelope as a memento -- maybe I can just send that one on to save the dollar! JDH
"John Hunter" <jd...@gm...> writes: > Actually, I think I saved that in the freezer still in the envelope as > a memento -- maybe I can just send that one on to save the dollar! That sounds like something that could get me in trouble with Finnish customs officials. I may have an opportunity to visit San Jose in August -- that's at least on the same continent as you, right? :-) -- Jouni K. Seppänen http://www.iki.fi/jks