Can we control where Matplotlib places figures on the screen?
I want to generate four figures (in four separate windows) that do not overlap.
Can we control where Matplotlib places figures on the screen?
I want to generate four figures (in four separate windows) that do not overlap.
在IPython中,您可以执行以下操作:
figure()
get_current_fig_manager().window.wm_geometry("400x600+20+40")
或者等效地在 Python 脚本中:
import pylab as pl
pl.figure()
pl.get_current_fig_manager().window.wm_geometry("400x600+20+40")
pl.show()
请注意,这假设您使用的是 TkAgg 后端。
也可以使用带有 Qt 后端的 IPython 接口来实现类似的结果:
import matplotlib
import pylab as pl
f1 = pl.figure()
f_manager = pl.get_current_fig_manager()
f_manager.window.move(600, 600)
pl.show()
使用 f_manager 你基本上有一个 PyQt4 对象,它允许你根据需要修改窗口属性。
我知道的最简单的方法是在您首选的 GUI 应用程序中为图形创建窗口,然后将 matplotlib 图形放入此窗口。这里有很多关于如何使用不同的 GUI 框架进行嵌入的示例。
代码示例可能看起来有点复杂,但它主要是样板文件,您只需要修改几行。
不单独使用show()和 Matplotlib。最简单的解决方案可能是使用savefig(..)并使用您最喜欢的 OS 图像查看器。如果您需要与绘图进行交互,Matplotlib 提供了后端。