开始使用免费开始使用

绘制各个分量

您也可以从时间序列分解对象中提取其他推断得到的量。下面的代码演示了如何提取观测值、趋势和噪声(或残差,resid)分量。

observed = decomposition.observed
trend = decomposition.trend
residuals = decomposition.resid

然后,您可以使用提取的分量分别进行绘图。

您在上一个练习中创建的 decomposition 对象已在工作区中提供。

本练习是课程的一部分

用 Python 可视化时间序列数据

查看课程

练习说明

  • decomposition 对象中提取 trend 分量。
  • 绘制该趋势分量。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Extract the trend component
trend = ____.____

# Plot the values of the trend
ax = ____.____(figsize=(12, 6), fontsize=6)

# Specify axis labels
ax.set_xlabel('Date', fontsize=10)
ax.set_title('Seasonal component the CO2 time-series', fontsize=10)
plt.show()
编辑并运行代码