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

查看:56
本文介绍了如何在 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 notebook 中内嵌图的问题在于它们的分辨率有限,我无法放大它们以查看一些较小的部分.使用从终端启动的 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天全站免登陆