1

I am using spyder with python to plot some images with matplotlib. When I generate a figure it is not showed on top of the windows, but hidden.

How can I get the figures on top?

I have this problem in Windows and Linux.

This is the code:

plt.figure(0)
plt.imshow(img)

Thanks for your help !

Community
  • 1
  • 1
betelgeuse
  • 430
  • 2
  • 10
  • 24

4 Answers4

3

I had the same problem, with Spyder 3.3.2, (python 3.7) and QT5 backend. The answer in this older query says you may use a trick with TkAgg backend. (at least, the trick does not work with my QT5 backend)

So I switched the backend in Spyder preferences (Tools==> Preferences ==> Ipython ==> Graphis ==> backend). and now, my windows already comes on top without any other tricks...

2diabolos.com
  • 992
  • 9
  • 15
1

Unfortunately there is no way to do what you're asking for because Matplotlib doesn't have the functionality to make it possible. See this issue for more details.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
0

This has been bugging me for a while and I've discovered an answer in an older query

Basically, make window "always on top", then undo that so that other windows can then come on top again.

Code to add after your plot:

#Put figure window on top of all other windows
fig.canvas.manager.window.attributes('-topmost', 1)
#After placing figure window on top, allow other windows to be on top of it later
fig.canvas.manager.window.attributes('-topmost', 0)
Community
  • 1
  • 1
  • This is only valid with the TkAgg backend. You may only change backend before you load pyplot. In Spyder, you may define in preferences the Backend "Tkinter", And then, the figure comes alone on top !!! – 2diabolos.com Dec 07 '18 at 11:49
0

I met the same problem yesterday. but I found that if you open the Ipython qtconsole at the same time, the figure window will turn out

Han Zhengzu
  • 3,694
  • 7
  • 44
  • 94