matplotlib.pyplot.subplots_adjust

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/asty9000/article/details/88881499

调整子图布局,调用格式如下:

subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)

参数

 有六个可选参数来控制子图布局。值均为0~1之间。其中left、bottom、right、top围成的区域就是子图的区域。wspace、hspace分别表示子图之间左右、上下的间距。实际的默认值由matplotlibrc文件控制的。

简单示例

import matplotlib.pyplot as plt

x=[1,2,3]
y=[4,5,6]
fig, axs = plt.subplots(2, 2)
axs[0, 0].plot(x,y)
axs[0, 1].plot(x,y)
axs[1, 0].plot(x,y)
axs[1, 1].plot(x,y)

plt.subplots_adjust(left=0.1, bottom=0.5, right=0.8, wspace=0.01)

plt.show()

运行结果如下:

猜你喜欢

转载自blog.csdn.net/asty9000/article/details/88881499