简体   繁体   English

Matplotlib绘图窗口出现在不同的桌面上

[英]Matplotlib plot window appears on different desktop

I am running Python 2.7.2 on Mac 10.8 with matplotlib 1.1.1. 我在Mac 10.8上使用matplotlib 1.1.1运行Python 2.7.2。 The backend I am using is MacOSX. 我使用的后端是MacOSX。 If I run any plotting code eg 如果我运行任何绘图代码,例如

import matplotlib.pyplot as plt
plt.plot([1,2,3], [4,5,6])
plt.show()

the plot window always appears on a different desktop from the one I am working on. 绘图窗口始终显示在与我正在处理的桌面不同的桌面上。 This behaviour is the same if I use ipython or if I run a script. 如果我使用ipython或运行脚本,此行为是相同的。 Is there a way around this? 有没有解决的办法? It's annoying to have to go and hunt for the plot each time! 每次都要去寻找情节是很烦人的!

If you previously moved it with OSX's desktop management commands you can fix it like this: 如果您之前使用OSX的桌面管理命令移动它,您可以像这样修复它:

Right click (Command click) on the Python Icon of the Matplotlib Icon in the Dock. 右键单击(命令单击)Dock中Matplotlib图标的Python图标。 Under Options there are options to assign the "application" to Desktops. 在“选项”下,可以选择将“应用程序”分配给桌面。 Set to none. 设置为无。 If it still opens in another desktop, move it to desktop you want it on (one way is to click and hold the header of the window... press Ctrl-#, where # is the desktop you want it on) 如果它仍在另一个桌面上打开,请将其移动到您想要的桌面上(一种方法是单击并按住窗口的标题...按Ctrl-#,其中#是您想要的桌面)

Source 资源

import matplotlib
matplotlib.use("wx")
from pylab import *
figure(1)
plot([1,2,3,4,5])
thismanager = get_current_fig_manager()
thismanager.window.SetPosition((500, 0))
show()

For TkAgg , just change it to: 对于TkAgg ,只需将其更改为:

thismanager.window.wm_geometry("+500+0")

I found this to be pretty helpful actually: matplotlib window layout questions 我发现这实际上非常有用: matplotlib窗口布局问题

Although, it seems that Brian has beat me to it. 虽然,Brian似乎已经打败了我。 Have you checked out WXAgg? 你看过WXAgg了吗?

>>> import matplotlib
>>> matplotlib.get_backend()
'WXAgg'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM