Pyplot窗口在Windows 7中显示为最顶层窗口

时间:2015-04-03 16:08:41

标签: python windows matplotlib anaconda spyder

我在Spyder环境中使用带有Python 2.7的Anaconda。在绘制一个pyplot时,窗口隐藏在我所有其他打开的窗口后面而不是出现在前面。如何让图形出现在所有其他打开的窗口前面?

matplotlib后端是:Qt4Agg

2 个答案:

答案 0 :(得分:4)

Spyder dev here )具有此功能的唯一后端是TkAgg。 @valentin在他/她的回答中发布的代码应该在使用该后端时起作用。

所有其他后端都错过了这种可能性。这已成为Matplotlib的一个已知限制已有相当长的一段时间,如Github issue所示。

答案 1 :(得分:3)

您可以尝试以下内容:

fig = plt.figure()
plt.show()

fig.canvas.manager.window.activateWindow()
fig.canvas.manager.window.raise_()

但是期望的行为依赖于后端。 在tkinter:

fm = plt.get_current_fig_manager() 
#bring to front
fm.window.attributes('-topmost', 1)
#allow other windows to cover
fm.window.attributes('-topmost', 0)