import matplotlib
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
x = np.linspace(0, 3*np.pi, 500)
plt.plot(x, np.sin(x**2))
plt.title('A simple chirp')
plt.show()
<matplotlib.figure.Figure at 0x110b9c450>
I did the anaconda install but matplotlib is not plotting
It starts plotting when i did this
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
I used%matplotlib inline in the first cell of the notebook and it works. I think you should try:
%matplotlib inline
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
You can also always start all your IPython kernels in inline mode by default by setting the following config options in your config files:
c.IPKernelApp.matplotlib=<CaselessStrEnum>
Default: None
Choices: ['auto', 'gtk', 'gtk3', 'inline', 'nbagg', 'notebook', 'osx', 'qt', 'qt4', 'qt5', 'tk', 'wx']
Configure matplotlib for interactive use with the default matplotlib backend.
If your matplotlib version is above 1.4, it is also possible to use
IPython 3.x and above
%matplotlib notebook
import matplotlib.pyplot as plt
older versions
%matplotlib nbagg
import matplotlib.pyplot as plt
Both will activate the nbagg backend, which enables interactivity.
To make matplotlib inline by default in Jupyter (IPython 3):
Please note that adding this line to
Edit file ~/.ipython/profile_default/ipython_config.py
Add line c.InteractiveShellApp.matplotlib = 'inline'
ipython_notebook_config.py would not work. Otherwise it works well with Jupyter and IPython 3.1.0