mplcyberpunk
mplcyberpunk copied to clipboard
Savefig saves only background color
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.
Hi @miroslavtushev, could you provide a minimum working example?
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:
Other charts looked well:
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.