facecolor for legend with alpha and shadow

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

facecolor for legend with alpha and shadow

Slavin, Jonathan
Hi all,

I'm wondering why using shadow=True causes shading of the legend box when framealpha is set to a number.  That is, if I do:
fig,ax = plt.subplots()
ax.plot(x,y1,label='y1')
ax.plot(x,y2,label='y2')
ax.legend(framealpha=0.5,shadow=True)

The face color of the legend is gray.  There doesn't seem to be any reason for this, so I'm assuming it's a bug.  I've been looking through the docs and haven't found anything relevant - and haven't found any way around it other than turning off the shadow. Any help would be appreciated.

Regards,
Jon

--
________________________________________________________
Jonathan D. Slavin                 Harvard-Smithsonian CfA
[hidden email]       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
cell: (781) 363-0035             USA
________________________________________________________


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: facecolor for legend with alpha and shadow

Paul Hobson-2
Jon,

I think with the transparent legend face, you're seeing the dark shadow underneath it. This seems to be reflected when changing the alpha values.The shadow itself if is a polygon the same size of the legend, z-ordered below the legend itself, and offset slightly.

Does that explain this to you?
-Paul

On Tue, May 15, 2018 at 7:07 AM, Slavin, Jonathan <[hidden email]> wrote:
Hi all,

I'm wondering why using shadow=True causes shading of the legend box when framealpha is set to a number.  That is, if I do:
fig,ax = plt.subplots()
ax.plot(x,y1,label='y1')
ax.plot(x,y2,label='y2')
ax.legend(framealpha=0.5,shadow=True)

The face color of the legend is gray.  There doesn't seem to be any reason for this, so I'm assuming it's a bug.  I've been looking through the docs and haven't found anything relevant - and haven't found any way around it other than turning off the shadow. Any help would be appreciated.

Regards,
Jon

--
________________________________________________________
Jonathan D. Slavin                 Harvard-Smithsonian CfA
[hidden email]       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
cell: (781) 363-0035             USA
________________________________________________________


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users



_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: facecolor for legend with alpha and shadow

Slavin, Jonathan
Ah, yes that makes sense.  Though I would still say that the intention of having the shadow is to have at the edges and the method of using the polygon in that way is a simple method to get it.  Unfortunately the side effect of that is to cause that graying of the face of the legend when transparency is used.  Seems like it would not be an easy fix.

Jon

On Tue, May 15, 2018 at 1:29 PM, Paul Hobson <[hidden email]> wrote:
Jon,

I think with the transparent legend face, you're seeing the dark shadow underneath it. This seems to be reflected when changing the alpha values.The shadow itself if is a polygon the same size of the legend, z-ordered below the legend itself, and offset slightly.

Does that explain this to you?
-Paul

On Tue, May 15, 2018 at 7:07 AM, Slavin, Jonathan <[hidden email]> wrote:
Hi all,

I'm wondering why using shadow=True causes shading of the legend box when framealpha is set to a number.  That is, if I do:
fig,ax = plt.subplots()
ax.plot(x,y1,label='y1')
ax.plot(x,y2,label='y2')
ax.legend(framealpha=0.5,shadow=True)

The face color of the legend is gray.  There doesn't seem to be any reason for this, so I'm assuming it's a bug.  I've been looking through the docs and haven't found anything relevant - and haven't found any way around it other than turning off the shadow. Any help would be appreciated.

Regards,
Jon

--
________________________________________________________
Jonathan D. Slavin                 Harvard-Smithsonian CfA
[hidden email]       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
cell: (781) 363-0035             USA
________________________________________________________


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users





--
________________________________________________________
Jonathan D. Slavin                 Harvard-Smithsonian CfA
[hidden email]       60 Garden Street, MS 83
phone: (617) 496-7981       Cambridge, MA 02138-1516
cell: (781) 363-0035             USA
________________________________________________________


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users