1

For the life of me, I can not get matplotlib to display graphs in ipython inactively.

I've tried two approaches - each time, I get the same results:

In [10]: plot([1,2,3])
Out[10]: [<matplotlib.lines.Line2D at 0x104e9ca50>]

Here are the two approaches I have tried so far: Using the documentation as a guide, I tried two different approaches:

First:

ipython --pylab

plot([1,2,3])
xlabel('hi mom')

In [3]: plot([1,2,3])
Out[3]: [<matplotlib.lines.Line2D at 0x107e369d0>]

Second:

ipython
import numpy
import pylab

In [5]: pylab.plot([1,2,3])
Out[5]: [<matplotlib.lines.Line2D at 0x104ca7b90>]

How do I get the plot to display?

6
  • not clear what you mean by inactively in your text and iteratively in your title. Commented Jun 16, 2012 at 19:20
  • 1
    Call pylab.show(), or if you want them to pop up automatically, call pylab.ion() before creating a figure. Commented Jun 16, 2012 at 19:23
  • @PhilCooper Updated the title. My bad on the spelling. Commented Jun 16, 2012 at 19:25
  • @JoeKington Just tried both of those. Nothing 'popped up'. In [6]: pylab.ion() In [7]: pylab.plot([1,2,3]) Out[7]: [<matplotlib.lines.Line2D at 0x101d59b90>] In [8]: pylab.show() Commented Jun 16, 2012 at 19:26
  • 1
    @mikebmassey - Hmm... Are you running a remote session, by chance? If not, try @BrenBarn's suggestion. If you are running things remotely (e.g. through ssh), be sure you've enabled X-forwarding. Commented Jun 16, 2012 at 19:28

1 Answer 1

5

It's possible you have a non-GUI backend set. Try doing pylab.get_backend() to see what backend you have set. Look at the documentation here and here to see how to set your backend.

Sign up to request clarification or add additional context in comments.

2 Comments

Just checked: 'MacOSX'. I see how to change it via the documentation, but any suggestion on which one to use? For now, I'm messing around with matplotlib and will want the graph to refresh on my screen when I plot something new.
MacOSX should be a GUI backend according to the docs, so I don't know why it's not working. Assuming you're sure you've got it set to interactive mode (as suggested in comments above) you could try any of the other interactive backends listed on the doc page (e.g., TkAgg). You may also want to ask on the matplotlib mailing list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.