Adam
Adam

Reputation: 1817

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?

Upvotes: 1

Views: 56

Answers (1)

busybear
busybear

Reputation: 10590

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)

enter image description here

Upvotes: 1

Related Questions