make matplotlib plotting window pop up as the active one


Question

I'm working with python and matplotlib on mac os x. When I'm working on many different windows and I have to run a script which produces a plot, the plot window always open behind the active window and is very frustration having to switch between windows for looking at the image. Is it any why to decide the location of the plot window, and/or pop up it as foreground window?

thanks

1
33
11/20/2011 2:36:49 PM

Accepted Answer

I was bothered by exactly the same problem. I found finally a solution (in pylab mode, with qt4agg backend):

get_current_fig_manager().window.raise_()

or

fig = gcf()
fig.canvas.manager.window.raise_()

Regards, Markus

13
1/17/2014 11:16:04 AM

For me (OSX 10.10.2, Matplotlib 1.4.3), what works is changing the matplotlib backend to TkAgg. Before importing pyplot or anything, go:

import matplotlib
matplotlib.use('TkAgg')  

Plot windows now pop-up, and can be Command-Tab'ed to.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon