Aan de slagGa gratis aan de slag

Plot individual components

It is also possible to extract other inferred quantities from your time-series decomposition object. The following code shows you how to extract the observed, trend and noise (or residual, resid) components.

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

You can then use the extracted components and plot them individually.

The decomposition object you created in the last exercise is available in your workspace.

Deze oefening maakt deel uit van de cursus

Visualizing Time Series Data in Python

Cursus bekijken

Oefeninstructies

  • Extract the trend component from the decomposition object.
  • Plot this trend component.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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()
Code bewerken en uitvoeren