您可以选择绘图的位置,但这取决于后端。要检查这一点,
import matplotlib
matplotlib.get_backend()
再看this的回答各种调整方式。
例如,这适用于我在 linux 上使用Qt4Agg,
import matplotlib.pyplot as plt
#Choose the correct dimensions for your first screen
FMwidth = 1280
FMheight = 1024
#Choose the correct dimensions for your second screen
SMwidth = 1280
SMheight = 1024
fm = plt.get_current_fig_manager()
#Works with QT on linux
fm.window.setGeometry(FMwidth,0,SMwidth,SMheight)
这对windows可能更好
fm.window.wm_geometry("+500+0")
您还可以获取屏幕尺寸from,
from win32api import GetSystemMetrics
width = GetSystemMetrics(0)
weight = GetSystemMetrics(1)
您可以轻松地创建一个计数器,每当您创建一个绘图并调整此指定位置时,该计数器就会递增,以便每次下一个绘图都在前一个绘图旁边。但是,如果您使用子图(例如设置 2 x 3 网格),大小和布局会容易得多,
#Setup 2 by 3 grid of subplots
fig, axs = plt.subplots(2,3,figsize=(width,height))
axs[0,0].plot(x, np.sinc(x))
axs[1,0].hist(y)
etc
然后,您可以使用计数器来指定您当前正在使用的绘图,并在绘图时递增。