【发布时间】:2020-01-16 19:38:13
【问题描述】:
我有以下代码用于生成时间序列图
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
series = pd.Series([np.sin(ii*np.pi) for ii in range(30)],
index=pd.date_range(start='2019-01-01', end='2019-12-31',
periods=30))
series.plot(ax=ax)
我想为 x 和 y 设置一个自动限制,我尝试使用 ax.margins() 但它似乎不起作用:
ax.margins(y=0.1, x=0.05)
# even with
# ax.margins(y=0.1, x=5)
我正在寻找的是一种自动方法,例如 padding=0.1(图表周围 10% 的空白)
【问题讨论】: