我正在尝试在 ipython 笔记本中创建交互式绘图。我正在尝试从 matplotlib 的网站运行示例代码,如下所示。
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 有关。这可能修复吗?以及如何?
谢谢!!!
最佳答案
如果您使用以下方式启动 ipython notebook:
ipython notebook --pylab=inline
您不需要 show()
函数调用。图将自动显示。只有当您使用 qt
、wx
、gtk
之一时才需要 show()
函数...后端。
此外,ginput()
函数在inline
模式下不可用。如果需要,您应该使用已安装的其他后端启动笔记本。例如qt
或tk
:
ipython notebook --pylab=qt
ipython notebook --pylab=tk
关于python - ipython 笔记本和 ginput,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18839341/