如何在IPython Notebook中打开交互式matplotlib窗口? [英] How can I open the interactive matplotlib window in IPython notebook?

查看:454
本文介绍了如何在IPython Notebook中打开交互式matplotlib窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将IPython与--pylab=inline一起使用,有时想快速切换到交互式,可缩放的matplotlib GUI来查看图(在终端Python控制台中绘制图时会弹出的图).我该怎么办?最好不要离开或重新启动笔记本.

I am using IPython with --pylab=inline and would sometimes like to quickly switch to the interactive, zoomable matplotlib GUI for viewing plots (the one that pops up when you plot something in a terminal Python console). How could I do that? Preferably without leaving or restarting my notebook.

IPy笔记本中的内联图的问题在于它们的分辨率有限,我无法放大以查看一些较小的部分.使用从终端启动的maptlotlib GUI,我可以选择要放大的图形矩形,并相应地调整轴.我尝试过

The problem with inline plots in IPy notebook is that they are of a limited resolution and I can't zoom into them to see some smaller parts. With the maptlotlib GUI that starts from a terminal, I can select a rectangle of the graph that I want to zoom into and the axes adjust accordingly. I tried experimenting with

from matplotlib import interactive
interactive(True)

interactive(False)

但是什么也没做.我也找不到在线提示.​​

but that didn't do anything. I couldn't find any hint online either.

推荐答案

根据文档,您应该可以像这样来回切换:

According to the documentation, you should be able to switch back and forth like this:

In [2]: %matplotlib inline 
In [3]: plot(...)

In [4]: %matplotlib qt  # wx, gtk, osx, tk, empty uses default
In [5]: plot(...) 

,这将弹出一个常规绘图窗口(可能需要在笔记本计算机上重新启动).

and that will pop up a regular plot window (a restart on the notebook may be necessary).

我希望这会有所帮助.

这篇关于如何在IPython Notebook中打开交互式matplotlib窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆