简体   繁体   中英

Interactively Display graphs in matplotlib in python

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM