Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib window appears at the back?

Whenever I call show() in matplotlib the plot window appears behind all other windows and I have to minimize everything to see it. Is there any way I can prevent this or programmatically bring it to the front. On OSX Lion. Python 2.7

like image 318
nickponline Avatar asked Apr 30 '12 22:04

nickponline


1 Answers

Well. This answer is presented in the comments to the accepted answer but I think it deserves to have a place as a separate one as it solves the issue nicely. Besides the author's problem I additionally had the problem that matplotlib window wasn't in the tray of active windows so I couldn't switch to it by <Alt>+<Tab>.

Changing of the matplotlib's default backend macosx solved everything. You can try immediately in your code like this:

import matplotlib
matplotlib.use("Qt5agg")

Qt5agg might not be presented in your system then please pick the one that is. You can find them:

import matplotlib.rcsetup as rcsetup
print(rcsetup.all_backends)

If it helped then you might want to change your backend in the configuration. For that locate it first:

import matplotlib
matplotlib.matplotlib_fname()

Then change backend: value:

backend      : macosx

to your backend. I used in the end:

backend      : TkAgg
like image 153
vogdb Avatar answered Nov 15 '22 15:11

vogdb