Choosing a plotting backend
There are different ways to display a plot in the Jupyter Notebook.
Inline plots
So far, we have created plots within the Notebook using the matplotlib inline mode. This is activated with the %matplotlib inline
magic command in the Notebook. Figures created in this mode are converted to PNG images stored within the notebook .ipynb
files. This is convenient when sharing notebooks because the plots are viewable by other users. However, these plots are static, and they are therefore not practical for interactive visualization.
Here is an example:
In [1]: import numpy as np import matplotlib.pyplot as plt In [2]: %matplotlib inline In [3]: plt.imshow(np.random.rand(10, 10), interpolation='none')
Exported figures
Matplotlib can export figures to bitmap (PNG, JPG, and others) or vector formats (PDF, EPS, and others). Refer to the documentation of plt.savefig()
for more details: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.savefig.