4

I'm trying to use matplotlib for chart visualizations, but it is very annoying to look for a window each time I run the project. Is there any way to force it to be on top of other windows? I use OSX 10.8 and PyCharm IDE and already tried

from pylab import get_current_fig_manager() get_current_fig_manager().window.raise_() 

Which fails with

AttributeError: 'FigureManagerMac' object has no attribute 'window' 

I'd appreciate any other ideas.

1
  • You are trying this after using show()? Commented Oct 9, 2013 at 8:35

3 Answers 3

2

you're call to window.raise_() is from PyQT. Indeed, you can raise the window in this way but you need to:

  • set PyQT4 as your backend before you do any other business with matplotlib

And

import matplotlib matplotlib.use('Qt4Agg') 
  • Either you fix you import statement (remove the brackets) or save yourself the import and access the window through the figure

with

window = fig.canvas.manager.window 
  • Only then you can call window.raise_() and the window will be in front of pycharm.
Sign up to request clarification or add additional context in comments.

1 Comment

Worked like a charm also with matplotlib.use('Qt5Agg')
1

This works for me from IPython:

from pylab import get_current_fig_manager fm = get_current_fig_manager() fm.show() 

I haven't found a case in which show() doesn't work by itself, though.

Comments

1

[cphlewis] had a great answer. I found myself doing this so often that I def a little function to pop all my windows up to the surface:

def pop_all(): #bring all the figures hiding in the background to the foreground all_figures=[manager.canvas.figure for manager in matplotlib.\ _pylab_helpers.Gcf.get_all_fig_managers()] [fig.canvas.manager.show() for fig in all_figures] return len(all_figures) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.