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

[Bug]: mplstyle figure.dpi is ignored in first plot #24361

Closed
grinsted opened this issue Nov 4, 2022 · 1 comment
Closed

[Bug]: mplstyle figure.dpi is ignored in first plot #24361

grinsted opened this issue Nov 4, 2022 · 1 comment

Comments

@grinsted
Copy link

grinsted commented Nov 4, 2022

Bug summary

When you load a stylesheet with a figure.dpi setting, then the dpi setting is not honored in the first figure. (It is honored in subsequent figures).

Code for reproduction

import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
from pathlib import Path
cfgdir = mpl.get_configdir()

# --- First create a custom style file with just a dpi setting ---
p = Path(cfgdir)
stylelib = (p / 'stylelib')
stylelib.mkdir(exist_ok=True)
path = stylelib / 'mplbug.mplstyle'
path.write_text("figure.dpi: 200")

plt.style.reload_library()

x = np.cos(np.linspace(0,4*np.pi,200))
plt.style.use('mplbug')
plt.plot(x)

Actual outcome

when i run this exact code two times in a row in a jupyter notebook, then the figure size is not the same the two times. It is wrong in the first figure.

Expected outcome

I expect the figure to be big the first time and all subsequent times.

Additional information

No response

Operating system

Windows

Matplotlib Version

3.5.2

Matplotlib Backend

module://ipykernel.pylab.backend_inline

Python version

3.8.5

Jupyter version

6.1.4

Installation

conda

@QuLogic
Copy link
Member

QuLogic commented Nov 5, 2022

This is a duplicate of #23007, and I believe you would need to update matplotlib-inline to fix it.

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

No branches or pull requests

3 participants