I think I may have found a bug in v3.5.2. See rcParams doesn't work the first time - Notebook - Jupyter Community Forum. Steps to reproduce
- install jupyter=3.5.2 and matplotlib>3 in fresh conda environment from conda-forge channel.
- import mpl, set
rcParams['figure.figsize'] = (12, 8)
and plot anything
- figure size is still default.
- re-execute cells again, now figure size is updated
- downgrade to mpl-3.5.1 and figure size is correctly updated first time
IDK, maybe gh23007 might be related?
Yes, I believe that is the same issue and is fixed by Remove matplotlib rc overrides. by fperez · Pull Request #14 · ipython/matplotlib-inline · GitHub on the matplotlib-inline side (they were setting rcparams on import).
The chain of changes here is that
-
matplotlib-inline
(and the inline backend in IPython
that it is the extracted code from) unconditionally set some slightly opinionated rcparams on import
- in mpl 3.5.2 we defered actually importing the backend until we actually really had to (when the user first actually creates a figure), previously we did it eagerly at pyplot import.
- thus we unintentionally moved the setting of the rcparams in
matplotlib-inline
until after where you are setting them and hence the squash your changes
I suspect that importing matplotlib-inline
before setting the rcparams will fix it as well (but have not verified that).
1 Like