-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: First invocation of plt.plot() resets mpl.rcParams['figure.dpi'] #23007
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
Comments
We really need to solidify if rcParams track current state or not. I pretty strongly feel they should not track current state - the figure or its canvas tracks that. I think rcParams should be read-only from the library's point of view. |
Agreed, but AFAICT this does not come from us, but from IPython's integration at https://github.com/ipython/matplotlib-inline/blob/10234a68898f353add344d1c73122df53839fe1b/matplotlib_inline/config.py#L38-L54 and https://github.com/ipython/matplotlib-inline/blob/10234a68898f353add344d1c73122df53839fe1b/matplotlib_inline/backend_inline.py#L182 |
I can confirm that it does not happen in a stand-alone script (and that it has only been tested in Jupyter lab 3.4.0). |
This has newly appeared in 3.5.2 due to #22005 making IPython's integration code run at the first use instead of at import. Before, it would just override the relevant values set in the matplotlibrc file and not interfere with any runtime changes to rcParams. |
Sigh, making this lazier always produces interesting unintended consequences.
I think the only rcParam that we mutate for the user is the save-folder location (which the user has to opt-into the behavior). We had a long discussion about that and concluded it was better to just leave that as it is rather than go through the effort of deprecating that behavior and moving the global state someplace else for the sake of aesthetics. |
I'm having this problem too, with |
Has anyone reported this to matplotlib-inline? |
This PR in matplotlib-inline would fix the issue - ipython/matplotlib-inline#14 |
I am having the same issue and I thought it was because of a new vscode release (microsoft/vscode-jupyter#9991 (comment)) but it also happens in google colab |
Remove matplotlib rc overrides. Addresses: - ipython/ipython#10383 - matplotlib/matplotlib#23007
I was having a similar issue with |
was released in matplotlib-inline 0.1.4 (Aug. 14, 2022). So I think we can close this. |
Bug summary
First invocation of
plt.plot()
resetsmpl.rcParams['figure.dpi']
.Code for reproduction
Actual outcome
300.0
72.0
Expected outcome
300.0
300.0
Additional information
This happens only at the very first invocation of
plt.plot()
, while on subsequentplt.plot()
callsmpl.rcParams['figure.dpi']
will no longer be overwritten.Other
rcParams
values seem not to be affected (but I've not tested them all).I have never observed this behavior in any of the previous matplotlib versions, so the bug must have been introduced in the latest version (3.5.2).
Operating system
Windows 10
Matplotlib Version
3.5.2
Matplotlib Backend
module://matplotlib_inline.backend_inline
Python version
Python 3.9.12
Jupyter version
3.4.0
Installation
conda
The text was updated successfully, but these errors were encountered: