1 回答
TA贡献1943条经验 获得超7个赞
我认为,当您使用 时bbox_inches="tight",您会缩短图形以删除空白,并且不会延长轴。
对我来说使用constrained_layout = true或plt.tight_layout()在乳胶下工作。
import matplotlib.pyplot as plt
xwidth = 418.25555 / 72 # conversion from in to pt
ywidth = 300 / 72 # conversion from in to pt
fig,ax = plt.subplots(figsize=[xwidth, ywidth], constrained_layout = True)
ax.plot([1,2,3],[1,2,3])
ax.set_ylabel("Y-label")
ax.set_xlabel("X-label")
fig.savefig("test.pdf")
或者
import matplotlib.pyplot as plt
xwidth = 418.25555 / 72 # conversion from in to pt
ywidth = 300 / 72 # conversion from in to pt
fig,ax = plt.subplots(figsize=[xwidth, ywidth])
ax.plot([1,2,3],[1,2,3])
ax.set_ylabel("Y-label")
ax.set_xlabel("X-label")
plt.tight_layout()
fig.savefig("test.pdf")
添加回答
举报