.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plotting/_taylor.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plotting__taylor.py: ================== 6.15 taylor plot ================== .. GENERATED FROM PYTHON SOURCE LINES 7-16 .. code-block:: default import numpy as np from easy_mpl import taylor_plot from easy_mpl.utils import version_info version_info() # sphinx_gallery_thumbnail_number = -1 .. rst-class:: sphx-glr-script-out .. code-block:: none {'easy_mpl': '0.21.4', 'matplotlib': '3.8.4', 'numpy': '1.26.4', 'pandas': '1.5.3', 'scipy': '1.13.1'} .. GENERATED FROM PYTHON SOURCE LINES 17-41 .. code-block:: default # The desired covariance matrix. cov = np.array( [[1, 0.8, 0.6, 0.4, 0.2], [0.8, 1.2, 0.8, 0.6, 0.4], [0.6, 0.8, 0.8, 0.8, 0.6], [0.4, 0.6, 0.8, 1.4, 0.8], [0.2, 0.4, 0.6, 0.8, 0.6]] ) # Generate the random samples. rng = np.random.default_rng(313) data = rng.multivariate_normal(np.zeros(5), cov, size=100) print(data.shape) observations = data[:, 0] simulations = {"LSTM": data[:, 1], "CNN": data[:, 2], "TCN": data[:, 3], "CNN-LSTM": data[:, 4]} _ = taylor_plot(observations=observations, simulations=simulations, title="Taylor Plot") .. image-sg:: /auto_examples/plotting/images/sphx_glr__taylor_001.png :alt: Taylor Plot :srcset: /auto_examples/plotting/images/sphx_glr__taylor_001.png, /auto_examples/plotting/images/sphx_glr__taylor_001_2_0x.png 2.0x :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/python-seekho/checkouts/dev/scripts/plotting/_taylor.py:29: RuntimeWarning: covariance is not symmetric positive-semidefinite. data = rng.multivariate_normal(np.zeros(5), cov, size=100) (100, 5) .. GENERATED FROM PYTHON SOURCE LINES 42-43 multiple taylor plots in one figure .. GENERATED FROM PYTHON SOURCE LINES 43-128 .. code-block:: default def create_data(cov, seed=313, mu=np.zeros(5), size=100): # Generate the random samples. rng = np.random.default_rng(seed) return rng.multivariate_normal(np.zeros(5), cov, size=size) cov1 = np.array( [[1, 0.8, 0.6, 0.4, 0.2], [0.8, 1.2, 0.8, 0.6, 0.4], [0.6, 0.8, 0.8, 0.8, 0.6], [0.4, 0.6, 0.8, 1.4, 0.8], [0.2, 0.4, 0.6, 0.8, 0.6]] ) cov2 = np.array( [[1, 0.8, 0.6, 0.4, 0.2], [0.8, 1.2, 0.8, 0.6, 0.4], [0.6, 0.8, 0.8, 0.8, 0.6], [0.4, 0.6, 0.8, 1.4, 0.8], [0.2, 0.4, 0.6, 0.8, 0.6]] ) cov3 = np.array( [[1, 0.8, 0.6, 0.4, 0.2], [0.8, 1.2, 0.8, 0.6, 0.4], [0.6, 0.8, 0.8, 0.8, 0.6], [0.4, 0.6, 0.8, 1.4, 0.8], [0.2, 0.4, 0.6, 0.8, 0.6]] ) cov4 = np.array( [[1, 0.8, 0.6, 0.4, 0.2], [0.8, 1.2, 0.8, 0.6, 0.4], [0.6, 0.8, 0.8, 0.8, 0.6], [0.4, 0.6, 0.8, 1.4, 0.8], [0.2, 0.4, 0.6, 0.8, 0.6]] ) site1_data = create_data(cov1) site2_data = create_data(cov2) site3_data = create_data(cov3) site4_data = create_data(cov4) observations = { 'site1': site1_data[:, 0], 'site2': site2_data[:, 0], 'site3': site3_data[:, 0], 'site4': site4_data[:, 0], } simulations = { "site1": {"LSTM": site1_data[:, 1], "CNN": site1_data[:, 2], "TCN": site1_data[:, 3], "CNN-LSTM": site1_data[:, 4]}, "site2": {"LSTM": site2_data[:, 1], "CNN": site2_data[:, 2], "TCN": site2_data[:, 3], "CNN-LSTM": site2_data[:, 4]}, "site3": {"LSTM": site3_data[:, 1], "CNN": site3_data[:, 2], "TCN": site3_data[:, 3], "CNN-LSTM": site3_data[:, 4]}, "site4": {"LSTM": site4_data[:, 1], "CNN": site4_data[:, 2], "TCN": site4_data[:, 3], "CNN-LSTM": site4_data[:, 4]}, } # define positions of subplots rects = dict(site1=221, site2=222, site3=223, site4=224) _ = taylor_plot(observations=observations, simulations=simulations, axis_locs=rects, plot_bias=True, cont_kws={'colors': 'blue', 'linewidths': 1.0, 'linestyles': 'dotted'}, grid_kws={'axis': 'x', 'color': 'g', 'lw': 1.0}, title="mutiple subplots") .. image-sg:: /auto_examples/plotting/images/sphx_glr__taylor_002.png :alt: mutiple subplots, Site1, Site2, Site3, Site4 :srcset: /auto_examples/plotting/images/sphx_glr__taylor_002.png, /auto_examples/plotting/images/sphx_glr__taylor_002_2_0x.png 2.0x :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/python-seekho/checkouts/dev/scripts/plotting/_taylor.py:49: RuntimeWarning: covariance is not symmetric positive-semidefinite. return rng.multivariate_normal(np.zeros(5), cov, size=size) .. GENERATED FROM PYTHON SOURCE LINES 129-130 using statistics instead of arrays .. GENERATED FROM PYTHON SOURCE LINES 130-144 .. code-block:: default observations = {'std': 3.5} predictions = { # pbias is optional 'Model 1': {'std': 2.80068, 'corr_coeff': 0.49172, 'pbias': -8.85}, 'Model 2': {'std': 3.8, 'corr_coeff': 0.67, 'pbias': -19.76}, 'Model 3': {'std': 3.9, 'corr_coeff': 0.596, 'pbias': 7.81}, 'Model 4': {'std': 2.36, 'corr_coeff': 0.27, 'pbias': -22.78}, 'Model 5': {'std': 2.97, 'corr_coeff': 0.452, 'pbias': -7.99}} _ = taylor_plot(observations, predictions) .. image-sg:: /auto_examples/plotting/images/sphx_glr__taylor_003.png :alt: taylor :srcset: /auto_examples/plotting/images/sphx_glr__taylor_003.png, /auto_examples/plotting/images/sphx_glr__taylor_003_2_0x.png 2.0x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 145-146 with customized markers .. GENERATED FROM PYTHON SOURCE LINES 146-168 .. code-block:: default cov = np.array( [[1, 0.8, 0.6, 0.4, 0.2], [0.8, 1.2, 0.8, 0.6, 0.4], [0.6, 0.8, 0.8, 0.8, 0.6], [0.4, 0.6, 0.8, 1.4, 0.8], [0.2, 0.4, 0.6, 0.8, 0.6]] ) data = create_data(cov) observations = data[:, 0] simulations = {"LSTM": data[:, 1], "CNN": data[:, 2], "TCN": data[:, 3], "CNN-LSTM": data[:, 4]} _ = taylor_plot(observations=observations, simulations=simulations, marker_kws={'markersize': 10, 'markeredgewidth': 1.5, 'markeredgecolor': 'black', 'lw': 0.0}) .. image-sg:: /auto_examples/plotting/images/sphx_glr__taylor_004.png :alt: taylor :srcset: /auto_examples/plotting/images/sphx_glr__taylor_004.png, /auto_examples/plotting/images/sphx_glr__taylor_004_2_0x.png 2.0x :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/python-seekho/checkouts/dev/scripts/plotting/_taylor.py:49: RuntimeWarning: covariance is not symmetric positive-semidefinite. return rng.multivariate_normal(np.zeros(5), cov, size=size) .. GENERATED FROM PYTHON SOURCE LINES 169-170 with customizing bbox .. GENERATED FROM PYTHON SOURCE LINES 170-179 .. code-block:: default _ = taylor_plot(observations=observations, simulations=simulations, title="custom_legend", leg_kws={'facecolor': 'white', 'edgecolor': 'black','bbox_to_anchor':(0.80, 1.1), 'fontsize': 14, 'labelspacing': 1.0}, marker_kws = {'ms':'20', 'markeredgecolor': 'k', 'lw': 0.0}, ) .. image-sg:: /auto_examples/plotting/images/sphx_glr__taylor_005.png :alt: custom_legend :srcset: /auto_examples/plotting/images/sphx_glr__taylor_005.png, /auto_examples/plotting/images/sphx_glr__taylor_005_2_0x.png 2.0x :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 3.567 seconds) .. _sphx_glr_download_auto_examples_plotting__taylor.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/AtrCheema/python-seekho/master?urlpath=lab/tree/notebooks/auto_examples/plotting/_taylor.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: _taylor.py <_taylor.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: _taylor.ipynb <_taylor.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_