Python 在 Spyder 中,使用具有交互式缩放等功能的 Matplotlib 绘图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36700083/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
In Spyder, plot using Matplotlib with interactive zoom, etc
提问by Kurt Peek
I've recently switched from Enthought Canopy to Anaconda and am using the Spyder IDE. I've noticed that when I plot some data,
我最近从 Enthought Canopy 切换到 Anaconda 并且正在使用 Spyder IDE。我注意到当我绘制一些数据时,
import matplotlib.pyplot as plt
plt.figure()
plt.plot(rigs2)
plt.ion()
plt.show()
It shows up as an inline figure in the IPython console:
它在 IPython 控制台中显示为内联图形:
However, in Enthought it used to be that the plot would show up in a separate window with zoom, back, and forward buttons. Is there any way to achieve the same in Spyder?
但是,在 Enthought 中,绘图会显示在带有缩放、后退和前进按钮的单独窗口中。有没有办法在 Spyder 中实现相同的目标?
回答by Norman
Select from the menu Tools > Preferences
, then IPython console
in the list of categories on the left, then the tab Graphics
at the top, and change the Graphics backend
from Inlineto e.g. Qt.
For me though, the figures then always pop up in the background.
(I use Spyder 3.0.0dev bundled with WinPython 3.4.)
从菜单中选择Tools > Preferences
,然后IPython console
在左侧,那么选项卡的类别列表Graphics
顶部,并改变Graphics backend
从内嵌到如Qt的。
不过对我来说,这些数字总是会出现在背景中。
(我使用与 WinPython 3.4 捆绑在一起的 Spyder 3.0.0dev。)
回答by DJV
Even though it's an old question, my solution to the same issue without using the GUI.
尽管这是一个老问题,但我在不使用 GUI 的情况下解决了同一问题。
Plot only in console:
仅在控制台中绘图:
%matplotlib inline
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
Going back to plot outside console:
回到控制台外的绘图:
%matplotlib qt5
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
There was no need to restart my spyder
or kernal.
Session info:
没有必要重新启动我的spyder
或内核。会话信息:
spyder 3.3.2
python 3.6.8
windows 10.
回答by jmir
And remember to restart the kernel and there it goes.
并记住重新启动内核,然后它就开始了。
回答by Frankfurt Ogunfunminiyi
You might not need to restart spyder. Just go to the tool menu and restart the kernel. Then you should have the plot displayed. Please, this is after you must have set the appropriate preferences for graphics
您可能不需要重新启动 spyder。只需转到工具菜单并重新启动内核即可。然后你应该显示绘图。请,这是在您必须为图形设置适当的首选项之后