I have made my plots inline on my Ipython Notebook with "%matplotlib inline
."
Now, the plot appears. However, it is very small. Is there a way to make it appear larger using either notebook settings or plot settings?
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
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
It is possible to scale the plot to full cell width.
svg
format instead of bitmap when mainly plotting line charts:%config InlineBackend.figure_format = 'svg'
%%html
<style>
.output_svg div{
width: 100% !important;
height: 100% !important;
}
</style>
A small but important detail for adjusting figure size on a one-off basis (as several commenters above reported "this doesn't work for me"):
You should do plt.figure(figsize=(,)) PRIOR to defining your actual plot. For example:
This should correctly size the plot according to your specified figsize:
values = [1,1,1,2,2,3]
_ = plt.figure(figsize=(10,6))
_ = plt.hist(values,bins=3)
plt.show()
Whereas this will show the plot with the default settings, seeming to "ignore" figsize:
values = [1,1,1,2,2,3]
_ = plt.hist(values,bins=3)
_ = plt.figure(figsize=(10,6))
plt.show()