我正在尝试修改图形,特别是我不喜欢在x轴上看左边和右边的空格,并希望它挤压以适应。
x轴的值是datetime对象。
xmin,xmax = plt.xlim()
print(xmax)
print(xmin)
返回
17707.15
16757.85
修改这些限制的正确方法是什么?我应该将正确的datetime对象转换为int并使用它设置xlim。或者matplotlib中是否有一个函数可以为我删除这些间隙(仅在x轴上)。
答案 0 :(得分:0)
ax.autoscale(enable=True, axis='x', tight=True)
制作
来自https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.autoscale.html