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

2024-04-27 00:14:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近从热情的天篷换成了水蟒,我正在使用Spyder IDE。我注意到当我绘制一些数据时

import matplotlib.pyplot as plt
plt.figure()
plt.plot(rigs2)
plt.ion()
plt.show()

它在IPython控制台中显示为内联图:

Result from the plt.plot() command

然而,过去人们总是兴高采烈地认为,该图将显示在一个单独的窗口中,并带有缩放、后退和前进按钮。Spyder有没有办法达到同样的效果?


Tags: 数据importplotmatplotlibas绘制pltide
3条回答

尽管这是个老问题,但我在不使用GUI的情况下解决了同样的问题。

仅在控制台中绘图:

%matplotlib inline 
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')

返回到绘图外部控制台:

%matplotlib qt5
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')

不需要重新启动我的spyder或内核。 会话信息:

spyder 3.3.2
python 3.6.8
windows 10. 

从菜单中选择Tools > Preferences,然后在左边的类别列表中选择IPython console,然后在顶部选择Graphics,然后将Graphics backendInline更改为例如Qt
但对我来说,数字总是在背景中出现。
(我使用与WinPython3.4捆绑在一起的Spyder 3.0.0dev。)

记住要重新启动内核,然后就这样了。

相关问题 更多 >