Skip to content

Figure background colors #7619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
darkdragon-001 opened this issue Dec 12, 2016 · 2 comments · Fixed by #15111
Closed

Figure background colors #7619

darkdragon-001 opened this issue Dec 12, 2016 · 2 comments · Fixed by #15111
Milestone

Comments

@darkdragon-001
Copy link

darkdragon-001 commented Dec 12, 2016

I find the current handling of background colors very non-intuitive:

  1. figure facecolor is not applied for savefig() by default
  2. figure facecolor is not applied setting frameon=False
  3. axis_bgcolor is not applied when hiding axis lines/ticks via axis('off')

So using a white plain surface to draw objects needs the following code:

fig = figure(..., facecolor='w', edgecolor='None')
ax.axis('equal')        # equal scale
ax.axis('off')          # do not show axis
ax.axis([-1, 1, -1, 1]) # scale to unit lengths
show()
fig.savefig(..., facecolor=fig.get_facecolor(), edgecolor='None', transparent=True)

My suggestion

  • apply same colors to savefig() by default
  • mention in the docs of axis_bgcolor and axis('off') that this setting is ignored
  • mention in the docs of facecolor and frameon that this setting is ignored
@tacaswell
Copy link
Member

We are always happy to get PRs to clarify documentation!

If you do not pass a facecolor it defaults to the value of rcParams['savefig.facecolor'] which should have defaulted to white.

It is less 'is not applied' than the background patches are simply not drawn if you ask them to not be drawn.

@Spenhouet
Copy link

Spenhouet commented May 25, 2019

Wow thanks for this thread. I was just about to write a bug report since my figures were always saved with a black facecolor instead of the correct white one (that is also rendered correct in IPython).

Just adding facecolor=fig.get_facecolor() to the save parameters solved this.
I agree that this is unintuitive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants