您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python-通过matplotlib中的许多子图来改善子图大小/间距

Python-通过matplotlib中的许多子图来改善子图大小/间距

试使用 plt.tight_layout

作为一个简单的例子:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(nrows=4, ncols=4)
fig.tight_layout() # Or equivalently,  "plt.tight_layout()"

plt.show()

没有紧凑的布局

您可以plt.subplots_adjust用来更改子图之间的间距(源)

通话签名:

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

参数含义(和建议的认值)为:

left  = 0.125  # the left side of the subplots of the figure
right = 0.9    # the right side of the subplots of the figure
bottom = 0.1   # the bottom of the subplots of the figure
top = 0.9      # the top of the subplots of the figure
wspace = 0.2   # the amount of width reserved for blank space between subplots
hspace = 0.2   # the amount of height reserved for white space between subplots

实际的认值由rc文件控制

python 2022/1/1 18:24:23 有465人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶