Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make matplotlib plotting window pop up as the active one

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

like image 318
Luca Fiaschi Avatar asked Nov 20 '11 14:11

Luca Fiaschi


People also ask

How do I change the plot window in matplotlib?

Import matplotlib. To change the figure size, use figsize argument and set the width and the height of the plot. Next, we define the data coordinates. To plot a bar chart, use the bar() function. To display the chart, use the show() function.

How do I make two matplotlib plots in one window?

In Matplotlib, we can draw multiple graphs in a single plot in two ways. One is by using subplot() function and other by superimposition of second graph on the first i.e, all graphs will appear on the same plot.

What is interactive mode in matplotlib?

Matplotlib can be used in an interactive or non-interactive modes. In the interactive mode, the graph display gets updated after each statement. In the non-interactive mode, the graph does not get displayed until explicitly asked to do so.

What can I use instead of %Matplotlib inline?

show() . If you do not want to use inline plotting, just use %matplotlib instead of %matplotlib inline .


2 Answers

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.

like image 186
Peter Avatar answered Oct 17 '22 05:10

Peter


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

like image 25
mrossi Avatar answered Oct 17 '22 05:10

mrossi