How to make IPython Notebook Matplotlib draw inline

This article was translated from: How to make IPython notebook matplotlib plot inline

I am trying to use IPython notebook on MacOS X with Python 2.7.2 and IPython 1.1.0. I am using IPython Notebook with Mac 2.7.2 and IPython 1.1.0 on MacOS X.

I cannot get matplotlib graphics to show up inline. I cannot get matplotlib graphics to display inline.

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline  

Also have have Tried the I %pylab inlineand the Command Line arguments The at The ipython --pylab=inlineBut the this Makes NO -difference. I also tried %pylab inlineand ipython command-line arguments --pylab=inlinebut that makes no difference.

x = np.linspace(0, 3*np.pi, 500)
plt.plot(x, np.sin(x**2))
plt.title('A simple chirp')
plt.show()

Instead of inline graphics, I get this: What I get is not inline graphics, but:

<matplotlib.figure.Figure at 0x110b9c450>

And matplotlib.get_backend()Shows that the I have have at The 'module://IPython.kernel.zmq.pylab.backend_inline'backend. matplotlib.get_backend()Show me 'module://IPython.kernel.zmq.pylab.backend_inline'the back end.


#1st Floor

Reference: https://stackoom.com/question/1JRRC/ How to make IPython-Notebook-Matplotlib inline drawing


#2nd Floor

I found a workaround that is quite satisfactory. I found a very satisfactory solution. Installed the I Anaconda Python and OUT of the this now at The Box Works for Me. I installed Anaconda Python , now for me out of the box.


#3rd floor

I'm not sure why joaquin posted his answer as a comment, but it is the correct answer: I'm not sure why Hua Jinfa expressed his answer as a comment, but this is the correct answer:

start ipython with ipython notebook --pylab inline a ipython notebook --pylab inlinestart ipython

Edit: Ok, this is now deprecated as per comment below . Use the %pylab inlinemagic command. Use the %pylab inlinemagic command.


#4th floor

I used the I %matplotlib inlinein the Cell at The First of Notebook and IT at The Works. I used in the first cell in the notebook %matplotlib inline, and can work properly. I think you should try: 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: By default, by setting the following configuration options in the configuration file, you can always always start all IPython in inline mode Kernel:

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.

#5th Floor

I have to agree with foobarbecue (I don't have enough recs to be able to simply insert a comment under his post): I must agree to foobarbecue (my advice is insufficient to simply insert a comment under his post ):

We're now Recommended that python Notebook IS not Started WIT at The argument --pylab, and ACCORDING to Fernando Perez (Creator of ipythonnb) %matplotlib inlineShould BE at The Initial Notebook the Command. Now is not recommended --pylabparameters to start python notebook, according to Fernando Perez (ipythonnb creator) of In other words, %matplotlib inlineit should be the initial command of the notebook.

See here: http://nbviewer.ipython.org/github/ipython/ipython/blob/1.x/examples/notebooks/Part%203%20-%20Plotting%20with%20Matplotlib.ipynb see here: http : //nbviewer.ipython.org/github/ipython/ipython/blob/1.x/examples/notebooks/Part%203%20-%20Plotting%20with%20Matplotlib.ipynb


#6th floor

I did the anaconda install but matplotlib is not plotting I did the anaconda installation, but matplotlib did not draw

It starts plotting when i did this when I do that it begin drawing

import matplotlib
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline  
Published 0 original articles · praised 75 · 560,000 views +

Guess you like

Origin blog.csdn.net/w36680130/article/details/105427683