Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python OSX如何将Matplotlib窗口置于前端?_Python_Macos_Matplotlib - Fatal编程技术网

Python OSX如何将Matplotlib窗口置于前端?

Python OSX如何将Matplotlib窗口置于前端?,python,macos,matplotlib,Python,Macos,Matplotlib,我尝试使用matplotlib进行图表可视化,但每次运行项目时都要寻找一个窗口,这非常烦人。有没有办法强迫它位于其他窗口的顶部?我使用OSX 10.8和PyCharm IDE,并且已经尝试过了 from pylab import get_current_fig_manager() get_current_fig_manager().window.raise_() 这与 AttributeError: 'FigureManagerMac' object has no attribute 'win

我尝试使用matplotlib进行图表可视化,但每次运行项目时都要寻找一个窗口,这非常烦人。有没有办法强迫它位于其他窗口的顶部?我使用OSX 10.8和PyCharm IDE,并且已经尝试过了

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

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

如果还有其他想法,我将不胜感激。

这在IPython对我来说很有用:

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

不过,我还没有发现show()本身不起作用的情况

您正在调用window.raise_uqt()来自PyQT。 实际上,您可以通过这种方式升起车窗,但您需要:

  • 使用
    matplotlib

  • 要么修复导入语句(删除括号),要么保存导入并通过图访问窗口

  • 只有这样,您才能调用
    window.raise()

    • [cphlewis]有一个很好的答案。我发现自己经常这样做,因此我定义了一个小功能,将所有窗口弹出到表面:

      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)
      

      您在使用
      show()
      后正在尝试此操作?在
      matplotlib.use('Qt5Agg')
      window = fig.canvas.manager.window
      
      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)