Matplotlib: How to prevent Jupyter from squeezing a large graph into a single cell?

Viewed 2354

Any time I try to plot a large graph in Jupyter with Matplotlib, where I would wish to scroll around the large image in the cell it has been rendered in, the notebook seems to squeeze the plot down to fit within its cell.

Normally, this is an optimal behavior, but how could I turn this off when I need to? How could I make plots display in their correct dimensions, given the ppi of one's screen?

1 Answers

Are you using the magic function %matplotlib inline ?

If so, you may be able to adjust either figure size or resolution to resize accordingly.

Adjust Figure Size (tends to distort text):

import matplotlib.pyplot as plt
%matplotlib inline
fig=plt.figure(figsize=(15, 15))

Global Option:

import matplotlib.pyplot as plt
%matplotlib inline
plt.rcParams['figure.figsize'] = [15, 15]

Adjust Resolution (doesn't distort text):

import matplotlib.pylab as plt
%matplotlib inline
plt.rcParams['figure.dpi'] = 200

Edit

Use the dropdowns: cell > all output > toggle scrolling (see screenshot)

enter image description here

Related