rcParams doesn't work the first time

I am seeing the strangest behavior in just one environment on one computer, and I can’t explain it or fix it. If I create two cells:

#%% 1st Cell
import matplotlib as mpl
from matplotlib import pyplot as plt
import seaborn as sns

#sns.set(font_scale=1.5, rc={'figure.figsize': (12, 8)})
mpl.rcParams['figure.figsize'] = (12, 8)

#%% 2nd cell
x, y = list(zip(*[(z, z*z) for z in range(10)]))
plt.plot(x, y)
plt.title('plot (x, y)')

Now if I restart the kernel and run all, I get a tiny figure. If I execute the 2 cells again using SHFT+ENTER then I get the correct size figure.

I’ve nuked the environment and rebuilt it from scratch with only python=3.7 matplotlib numpy pandas seaborn scipy ipython jupyter nbdime from conda-forge channel, and I still get this strange behavior. I’m completely lost…

I downgraded to mpl-3.5.1 and the problem went away. :confused:

This issue was already reported in mpl gh23007.

1 Like