Skip to content
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

Savefig saves only background color #10

Open
miroslavtushev opened this issue Nov 14, 2021 · 2 comments
Open

Savefig saves only background color #10

miroslavtushev opened this issue Nov 14, 2021 · 2 comments

Comments

@miroslavtushev
Copy link

Is there a fix for it? I'd like to be able to save my figs in higher dpi. But for some reason it only saves as a dark rectangle of the background color.

@dhaitz
Copy link
Owner

dhaitz commented Aug 11, 2022

Hi @miroslavtushev, could you provide a minimum working example?

@eoinmarron
Copy link

eoinmarron commented Jun 28, 2023

If I'm understanding your problem correctly, I was getting the exact same issue and intermittently - some charts generated fine, some had the cyberpunk-styled background and line objects but the chart area, axis text, title were not cyberpunk-styled:
image

Other charts looked well:
image

My setup was using a multiprocessing Pool() object to build many charts at once.
On each process, the following code was run:

fig, ax = pl.subplots(figsize=(15, 8))
if self.dark_mode:
      pl.style.use("cyberpunk")
else:
      pl.style.use("bmh")

To fix the issue, I simply moved the fig, ax assignment below the pl.style.use block:

if self.dark_mode:
      pl.style.use("cyberpunk")
else:
      pl.style.use("bmh")
fig, ax = pl.subplots(figsize=(15, 8))

For some reason doing the pl.style.use command only once before the Pool().starmap() didn't work. Presumably, each spawned process works with a fresh unaltered instance of matplotlib - this is speculation, my understanding here is not good.

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

No branches or pull requests

3 participants