You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: First invocation of plt.plot() resets mpl.rcParams['figure.dpi'] #23007
First invocation of plt.plot() resets mpl.rcParams['figure.dpi'].
Code for reproduction
# Only tested in Jupyterimportmatplotlibasmplimportmatplotlib.pyplotaspltmpl.rcParams['figure.dpi'] =300print(mpl.rcParams['figure.dpi'])
plt.plot()
print(mpl.rcParams['figure.dpi'])
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 subsequent plt.plot() calls mpl.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).
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.
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.
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
Sigh, making this lazier always produces interesting unintended consequences.
We really need to solidify if rcParams track current state or not. I pretty strongly feel they should not track current state ...
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 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
Activity
[-][Bug]: [/-][+][Bug]: First invocation of plt.plot() resets mpl.rcParams['figure.dpi'][/+]jklymak commentedon May 7, 2022
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.
anntzer commentedon May 8, 2022
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
emazep commentedon May 8, 2022
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).
yut23 commentedon May 9, 2022
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.
tacaswell commentedon May 10, 2022
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.
neon-ninja commentedon May 18, 2022
I'm having this problem too, with
plt.rcParams['figure.figsize']. Rolling back to matplotlib==3.5.1 withpip install matplotlib==3.5.1fixes ittacaswell commentedon May 18, 2022
Has anyone reported this to matplotlib-inline?
neon-ninja commentedon May 18, 2022
This PR in matplotlib-inline would fix the issue - ipython/matplotlib-inline#14
juanitorduz commentedon May 18, 2022
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
Merge pull request #14 from fperez/master
mikofski commentedon May 24, 2022
I was having a similar issue with
rcParams['figure.figsize'], see https://discourse.matplotlib.org/t/bug-rcparams-doesnt-work-first-time-v3-5-2/22853, downgrading to mpl-3.5.1 solved the issue. IDK if it's the same?timhoffm commentedon Oct 16, 2022
was released in matplotlib-inline 0.1.4 (Aug. 14, 2022). So I think we can close this.