The Guy
The Guy

Reputation: 718

Have Pyplot windows appear as topmost window in Windows 7

I am using Anaconda with Python 2.7 in the Spyder environment. When plotting a pyplot, the window hides behind all my other open windows instead of appear in front. How would I make the figure appear in front of all other open windows?

The matplotlib backend is: Qt4Agg

Upvotes: 1

Views: 1491

Answers (2)

Carlos Cordoba
Carlos Cordoba

Reputation: 34186

(Spyder dev here) The only backend that have this functionality is the TkAgg one. The code posted by @valentin in his/her answer should work when using that backend.

All other backends miss this possibility. This has been a known limitation of Matplotlib for quite some time, as can be seen in this Github issue.

Upvotes: 4

valentin
valentin

Reputation: 3608

You can try something like:

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

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

But the desired behaviour is backend dependent. On 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)

Upvotes: 4

Related Questions