Search code examples
pythonpython-2.7matplotlibipythonpythonxy

ipython not producing output graph using matplotlib


SO I have recently started trying to use ipython, I am finding I cannot get it to produce an output graph. I am running the following code in ipython:

from sklearn import linear_model
regr = linear_model.LinearRegression()

regr.fit(x, y)
pl.plot(x, y, 'o')
pl.plot(x_test, regr.predict(x_test))

and I am recieving the output:

[<matplotlib.lines.Line2D at 0x21d453b0>]

With no image attatched.

I installed ipython using the pythonxy package. Any thoughts of suggestions on methods to get plots outputting correctly in ipython

See attached image:
enter image description here


Solution

  • Try running in a cell:

    %pylab inline    # or
    %matplotlib inline
    

    After that the plots should be displayed inline. Alternatively start the notebook using the inline option in the command line:

    ipython notebook --pylab=inline