问题描述:

I run Ipthon in the terminal, in linux (not a jupyter notebook).

In Ipython 2.4.1, the following commands opens a pop up interactive Tk

plot window:

(prodEnv)[[email protected] sandbox]$ ipython

IPython 2.4.1 -- An enhanced Interactive Python.

? -> Introduction and overview of IPython's features.

%quickref -> Quick reference.

help -> Python's own help system.

object? -> Details about 'object', use 'object??' for extra details.

In [1]:

In [1]: %matplotlib

Using matplotlib backend: TkAgg

In [2]: import matplotlib.pyplot as plt

In [3]: import numpy as np

In [4]: plt.ion()

In [5]: x = np.arange(0, 4*np.pi, 0.1)

In [6]: y = [np.sin(i) for i in x]

In [7]: plt.plot(x, y, 'g-', linewidth=1.5, markersize=4)

Out[7]: [<matplotlib.lines.Line2D at 0x7f5c8a8b6410>]

In Ipython 5.0.0, when I use the same code:

(prodEnv)[[email protected] sandbox]$ ipython3

Python 3.4.1 (default, Nov 3 2014, 14:38:10)

Type "copyright", "credits" or "license" for more information.

IPython 5.0.0 -- An enhanced Interactive Python.

? -> Introduction and overview of IPython's features.

%quickref -> Quick reference.

help -> Python's own help system.

object? -> Details about 'object', use 'object??' for extra details.

In [1]: %matplotlib

...: import matplotlib.pyplot as plt

...: import numpy as np

...: plt.ion()

...: x = np.arange(0, 4*np.pi, 0.1)

...: y = [np.sin(i) for i in x]

...: plt.plot(x, y, 'g-', linewidth=1.5, markersize=4)

...:

Using matplotlib backend: agg

Out[1]: [<matplotlib.lines.Line2D at 0x7fe49ae9c208>]

nothing appears. How do I get my poping up interractive plot in Iptyhon 5.0.0?

网友答案:

From your output with ipython using TkAgg i.e. tk (python-tk) as backend.

Using matplotlib backend: TkAgg

But with ipython3, it is agg

Using matplotlib backend: agg

I try with ipython3 and TkAgg backend it's working just fine as ipython. You may need to install python3-tk to use TkAgg with matplotlib

相关阅读:
Top