ipython笔记本和ginput [英] ipython notebook and ginput
问题描述
我正在尝试在ipython笔记本中创建交互式绘图。我试图从matplotlib的网站运行示例代码,如下所示。
I am trying to create an interactive plot in ipython notebook. I am attempting to run the sample code from matplotlib's website as below.
t = arange(10)
plot(t, sin(t))
print("Please click")
x = ginput(3)
print("clicked",x)
show()
我收到此错误:
/Library/Python/2.7/site-packages/matplotlib/backend_bases.pyc in start_event_loop(self, timeout)
2370 This is implemented only for backends with GUIs.
2371 """
-> 2372 raise NotImplementedError
2373
2374 def stop_event_loop(self):
NotImplementedError:
我认为这与运行ipython notebook和HTML有关。这有可能解决吗?以及如何解决?
I assume this has something to do with running ipython notebook and HTML. Is this possible to fix? and how?
谢谢!!!
推荐答案
如果您使用以下方式启动ipython笔记本:
If you started the ipython notebook using:
ipython notebook --pylab=inline
您不需要 show()
函数调用。将自动显示图。 show()
仅当您使用 qt
, wx
,<$ c $之一时才需要此功能c> gtk ...后端。
You don't need the show()
function call. Plots will be automatically shown. The show()
function is needed only when you use one of the qt
, wx
, gtk
... backends.
此外, ginput()
函数在内联
模式下不可用。如果需要,您应该使用已安装的其他后端启动笔记本。例如 qt
或 tk
:
Also, the ginput()
function is not available in the inline
mode. If you need it, you should start the notebook using some other backend that you have installed. For example qt
or tk
:
ipython notebook --pylab=qt
ipython notebook --pylab=tk
这篇关于ipython笔记本和ginput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!