.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_multivariate_timeseries.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_multivariate_timeseries.py: Multivariate and time series ============================ Principal components and clustering (via scikit-learn), and a seasonal decomposition (via statsmodels), all redrawn in the depictr theme. .. GENERATED FROM PYTHON SOURCE LINES 8-16 .. code-block:: Python import numpy as np import pandas as pd import depictr as dp wb = dp.wellbeing_survey() .. GENERATED FROM PYTHON SOURCE LINES 17-18 A PCA biplot, coloured by group, with the variable loadings. .. GENERATED FROM PYTHON SOURCE LINES 18-21 .. code-block:: Python p = dp.pca_plot(wb, group="region") p .. image-sg:: /auto_examples/images/sphx_glr_plot_multivariate_timeseries_001.png :alt: plot multivariate timeseries :srcset: /auto_examples/images/sphx_glr_plot_multivariate_timeseries_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 22-23 k-means clusters on the first two principal components. .. GENERATED FROM PYTHON SOURCE LINES 23-26 .. code-block:: Python p = dp.cluster_plot(wb, k=3) p .. image-sg:: /auto_examples/images/sphx_glr_plot_multivariate_timeseries_002.png :alt: plot multivariate timeseries :srcset: /auto_examples/images/sphx_glr_plot_multivariate_timeseries_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 27-28 A monthly series with a trend, a 12-period season and noise. .. GENERATED FROM PYTHON SOURCE LINES 28-35 .. code-block:: Python rng = np.random.default_rng(0) t = np.arange(120) series = pd.Series( 50 + 0.3 * t + 10 * np.sin(2 * np.pi * t / 12) + rng.normal(0, 3, 120), index=pd.period_range("2016-01", periods=120, freq="M"), ) .. GENERATED FROM PYTHON SOURCE LINES 36-37 Its seasonal decomposition (observed, trend, seasonal, residual). .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: Python p = dp.decompose_plot(series, period=12) p .. image-sg:: /auto_examples/images/sphx_glr_plot_multivariate_timeseries_003.png :alt: plot multivariate timeseries :srcset: /auto_examples/images/sphx_glr_plot_multivariate_timeseries_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.823 seconds) .. _sphx_glr_download_auto_examples_plot_multivariate_timeseries.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_multivariate_timeseries.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_multivariate_timeseries.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_multivariate_timeseries.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_