简体   繁体   English

在Spyder中,使用Matplotlib和交互式缩放等进行绘图

[英]In Spyder, plot using Matplotlib with interactive zoom, etc

I've recently switched from Enthought Canopy to Anaconda and am using the Spyder IDE. 我最近从“有思想的檐篷”切换到“蟒蛇”,并且正在使用Spyder IDE。 I've noticed that when I plot some data, 我注意到当我绘制一些数据时,

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控制台中显示为嵌入式图形:

plt.plot()命令的结果

However, in Enthought it used to be that the plot would show up in a separate window with zoom, back, and forward buttons. 但是,在Enthought中,该图通常会在具有缩放,后退和前进按钮的单独窗口中显示。 Is there any way to achieve the same in Spyder? 有什么方法可以在Spyder中实现相同目的吗?

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 Inline to eg Qt . 从菜单Tools > Preferences ,然后在左侧的类别列表中选择IPython console ,然后在顶部的选项卡中选择Graphics ,然后将Graphics backend内联更改为例如Qt
For me though, the figures then always pop up in the background. 但是对我而言,这些数字总是在背景中弹出。
(I use Spyder 3.0.0dev bundled with WinPython 3.4.) (我使用了与WinPython 3.4捆绑在一起的Spyder 3.0.0dev。)

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. 无需重新启动我的spyder或内核。 Session info: 会话信息:

spyder 3.3.2
python 3.6.8
windows 10. 

并记住重新启动内核,然后就可以了。

You might not need to restart spyder. 您可能不需要重新启动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 拜托,这是在您必须为图形设置适当的首选项之后

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM