大家好,我正在尝试保存 matplotlib 中的数字。它保存图形周围的空白,我的意思是它增加了空间,它不保存调整后的对象大小。在 Inkscape 中编辑它们非常容易(我在这个软件中进行编辑),但是当图形超过 50 个时,这就不太好了。
我这样做是因为在投影仪幻灯片中,具有额外空间的图形占据了大量空间,因为纸张非常小。
使用约束布局。有一些可能性:
plt.figure
功能
# 3.5.3 and 3.6
fig = plt.figure(figsize=(8, 6), layout="constrained")
fig.add_subplot()
plt.plot([1, 2], [3, 4])
plt.subplots
功能
# 3.5.3 and 3.6
fig, ax = plt.subplots(figsize=(8, 6), layout="constrained")
ax.plot([1, 2], [3, 4])
创建后在Figure对象上设置布局:
# 3.5.3
fig.set_constrained_layout(True)
# 3.6
fig.set_layout_engine("constrained")
更多信息:
https://matplotlib.org/stable/tutorials/intermediate/constrainedlayout_guide.html#sphx-glr-tutorials-intermediate-constrainedlayout-guide-py https://matplotlib.org/stable/tutorials/intermediate/constrainedlayout_guide.html#sphx-glr-tutorials-intermediate-constrainedlayout-guide-py
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)