How to make inline plots in Jupyter Notebook larger?
Solution 1
Yes, play with figuresize
and dpi
like so (before you call your subplot):
fig=plt.figure(figsize=(12,8), dpi= 100, facecolor='w', edgecolor='k')
As @tacaswell and @Hagne pointed out, you can also change the defaults if it's not a one-off:
plt.rcParams['figure.figsize'] = [12, 8]
plt.rcParams['figure.dpi'] = 100 # 200 e.g. is really fine, but slower
Solution 2
The default figure size (in inches) is controlled by
matplotlib.rcParams['figure.figsize'] = [width, height]
For example:
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [10, 5]
creates a figure with 10 (width) x 5 (height) inches
Solution 3
I have found that %matplotlib notebook
works better for me than inline with Jupyter notebooks.
Note that you may need to restart the kernel if you were using %matplotlib inline
before.
Update 2019:
If you are running Jupyter Lab you might want to use
%matplotlib widget
Solution 4
If you only want the image of your figure to appear larger without changing the general appearance of your figure increase the figure resolution. Changing the figure size as suggested in most other answers will change the appearance since font sizes do not scale accordingly.
import matplotlib.pylab as plt
plt.rcParams['figure.dpi'] = 200
Solution 5
The question is about matplotlib
, but for the sake of any R users that end up here given the language-agnostic title:
If you're using an R kernel, just use:
options(repr.plot.width=4, repr.plot.height=3)
Chris
Prior Roles: Research Scientist (Physics, Aerospace, MBSE) @ GTRI: Electro-Optics Systems Lab Research Engineer (Cyber, Digital Signals Processing) @ GTRI/ECE Cyber Security Lab Machine Learning Engineer (Digital Advertising and Analytics) Sr. Software Engineer (Computer Vision, Machine Learning) Top Languages: Python3 C++ C Sports/Extra-curricular: Soccer/Football (the round ball you kick) Tae Kwon Do (amplifying the kicking synergy) Skiing Hobbies: CAD + CNC'ing dofabbles and widgets Salting my living space with tech magazines and cheap Dover books on Mathematics USB protocols Guitar Degrees: B.S. Physics M.S. Computer Science
Updated on April 26, 2021