Re: [Matplotlib-users] legend bg color?

On 9/11/07, Jose Gomez-Dans <jgomezdans@...> wrote:
> Hi Patrick,
>
> Thanks for your message!
>
> On 9/10/07, Patrick Bradley <patrick.bradley@...> wrote:
> > lg = legend()
> > lg.get_frame().set_fill(False)
>
> Mmmm, this is OK, let's say I wanted a figure with a transparent
> background. I can't find a set_fill() method for this class. I have
> tried the facecolor attribute, but no luck. I think I got this right.
> I am using the Agg backend (does this make a difference?). The files
> are RGBA pngs, but the alpha channel is always 255, so my background
> is always white, as opposed to transparent.
>
> Am I doing something wrong? I am using matplotlib 0.90.0. Here's some
> sample code
You can turn off the figure frame entirely
fig = figure(frameon=False)
Or you can leave the frame on, but set the alpha channel
fig = figure()
fig.figurePatch.set_alpha(0.1)
Does that help? Note you may want to set the alpha of the axesPatch as well
ax.axesPatch.set_alpha(0.5)
you can do the same for legends, where l is a Legend instance
l.legendPatch.set_alpha(0.5)
JDH

Thread view

Hi all,
Can you change the background of the figure legends generated by
matplotlib? I'd like to have some white-on-black figures for a few
presentations that I'm giving, and I can change the figure and axes
facecolor attributes accordingly (as well as the default text and axis label
colors), but I can't find an option anywhere to change the background of the
legend: it still shows up as a white box. Any ideas?
Thanks in advance.
Yours,
Patrick

Never mind - I missed a key point in the documentation. For anyone who's
wondering:
lg = legend()
lg.get_frame().set_facecolor('black')
works fine.
--Patrick
On 9/5/07, Patrick Bradley <patrick.bradley@...> wrote:
>
> Hi all,
>
> Can you change the background of the figure legends generated by
> matplotlib? I'd like to have some white-on-black figures for a few
> presentations that I'm giving, and I can change the figure and axes
> facecolor attributes accordingly (as well as the default text and axis label
> colors), but I can't find an option anywhere to change the background of the
> legend: it still shows up as a white box. Any ideas?
>
> Thanks in advance.
>
> Yours,
> Patrick
>

Hi,
On 9/5/07, Patrick Bradley <patrick.bradley@...> wrote:
> lg = legend()
> lg.get_frame().set_facecolor('black')
Does anyone know how to set this background to transparent? I think I
sent a message to the list a few days ago, but I think it never made
it...
Cheers!
Jose

On 9/11/07, Jose Gomez-Dans <jgomezdans@...> wrote:
> Hi Patrick,
>
> Thanks for your message!
>
> On 9/10/07, Patrick Bradley <patrick.bradley@...> wrote:
> > lg = legend()
> > lg.get_frame().set_fill(False)
>
> Mmmm, this is OK, let's say I wanted a figure with a transparent
> background. I can't find a set_fill() method for this class. I have
> tried the facecolor attribute, but no luck. I think I got this right.
> I am using the Agg backend (does this make a difference?). The files
> are RGBA pngs, but the alpha channel is always 255, so my background
> is always white, as opposed to transparent.
>
> Am I doing something wrong? I am using matplotlib 0.90.0. Here's some
> sample code
You can turn off the figure frame entirely
fig = figure(frameon=False)
Or you can leave the frame on, but set the alpha channel
fig = figure()
fig.figurePatch.set_alpha(0.1)
Does that help? Note you may want to set the alpha of the axesPatch as well
ax.axesPatch.set_alpha(0.5)
you can do the same for legends, where l is a Legend instance
l.legendPatch.set_alpha(0.5)
JDH

Community

Help

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

CountryState

JavaScript is required for this form.

I agree to receive quotes, newsletters and other information from sourceforge.net and its partners regarding IT services and products. I understand that I can withdraw my consent at any time. Please refer to our Privacy Policy or Contact Us for more details