首页 > 解决方案 > Matplotlib - 设置边距长度

问题描述

在 matplotlib 中以相对方式(例如比率)设置边距很容易;但是否有可能以绝对值表示,例如左边距 = 1 英寸等?

MWE,其中以英寸为单位提及图形尺寸。我希望边距也可以这样指定。

import matplotlib.pyplot as plt   

x = [1, 2, 3, 4]
y = [1, 4, 9, 6]

plt.figure(figsize=(10, 6))
plt.plot(x, y)
plt.margins(0.1)
plt.show()

请注意,问题不在于在图外设置填充。

标签: pythonmatplotlibmargin

解决方案


推荐阅读