简体   繁体   中英

Jupyter notebook (web interface) renders matplotlib plots 2x smaller

from matplotlib import pyplot
print(pyplot.rcParams['figure.figsize'])

returns [6.0, 4.0] . (that's supposed to be in inches)

But I measure half the size in the notebook's web interface. I can make the plot bigger, by setting rcParams['figure.figsize'] to double the size, but the text is small, then. I wonder if there's a fix, not this hack.

(The plots are inlined by default it seems, I don't use %matplotlib inline and if I do, nothing changes.)

I've seen some questions on how to make the plots bigger in jupyter notebook, so is this a known bug or something?

The issue sounds to be due to the figure being constrained by the size of your interface. The text is getting smaller because the plot is being scaled down to fit within your interface. If you save your figure as an image, you should be able to see that the figure size is changing.

Here is an example where the figures appear to be the same size within jupyter but are actually different sizes if saved to file:

np.random.seed(42)
Y = np.random.random(10)
plt.subplots(figsize=(24, 16))
plt.plot(Y)
plt.subplots(figsize=(6, 4))
plt.plot(Y)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM