简体   繁体   中英

Multiple figure arrangement using Matplotlib

Can we control where Matplotlib places figures on the screen?

I want to generate four figures (in four separate windows) that do not overlap.

From IPython you can do the following:

figure()
get_current_fig_manager().window.wm_geometry("400x600+20+40")

Or equivalently in a Python script:

import pylab as pl
pl.figure()
pl.get_current_fig_manager().window.wm_geometry("400x600+20+40")
pl.show()

Note that this assumes you're using the TkAgg backend.

It is also possible to use the IPython interface with the Qt backend to achieve a similar result:

import matplotlib
import pylab as pl
f1 = pl.figure()
f_manager = pl.get_current_fig_manager()
f_manager.window.move(600, 600)
pl.show()

With f_manager you basically have a PyQt4 object that allows you to modify the window properties as you like.

Not using show() and Matplotlib alone. The simplest solution may be to use savefig(..) and use your favorite OS image viewer. If you need interactivity with the plots, Matplotlib offers backends .

The easiest way I know to do this is to make the window for the figure in your preferred GUI application, and then put the matplotlib figure into this window. There are a bunch of examples of how to do this embedding using different GUI frameworks here .

The code samples can look a bit complicated, but it's mostly boilerplate where you'll only need to modify a few lines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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