.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_taylor_diagram.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_taylor_diagram.py: =========================== Plot Taylor Diagram =========================== This example uses fake data and fitted model prediction to plot taylor diagram The R package open-air has provided a nice explanation on what taylor diagram is: https://bookdown.org/david_carslaw/openair/sections/model-evaluation/taylor-diagram.html (Figure 20.2) .. GENERATED FROM PYTHON SOURCE LINES 11-49 .. image-sg:: /auto_examples/images/sphx_glr_plot_taylor_diagram_001.png :alt: plot taylor diagram :srcset: /auto_examples/images/sphx_glr_plot_taylor_diagram_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /home/docs/checkouts/readthedocs.org/user_builds/cgeniepy/envs/stable/lib/python3.12/site-packages/cgeniepy/skill.py:422: UserWarning: *c* argument looks like a single numeric RGB or RGBA sequence, which should be avoided as value-mapping will have precedence in case its length matches with *x* & *y*. Please use the *color* keyword-argument or provide a 2D array with a single row if you intend to specify the same RGB or RGBA value for all points. self.ax.scatter(np.arccos(correlation), std,*args, **kwargs) | .. code-block:: Python import numpy as np from scipy.optimize import curve_fit from cgeniepy.skill import ArrComparison, TaylorDiagram import matplotlib.pyplot as plt def generate_data(x, a, b, c, noise=0.5): y = a * np.exp(-b * x) + c # Exponential function np.random.seed(90148) noise = np.random.normal(0, noise, size=len(x)) return y + noise def exp_func(x, a, b, c): return a * np.exp(-b * x) + c def linear_func(x, a, b): return a * x + b # Generate random data x = np.linspace(0, 10, 50) y = generate_data(x, 5, 0.3, 2) ## linear model popt, pcov = curve_fit(linear_func, x, y) fit1 = linear_func(x, *popt) ## exp model popt2, pcov2 = curve_fit(exp_func, x, y) fit2 = exp_func(x, *popt2) ## Create Comparison instance ac1 = ArrComparison(y, fit1, 'linear') ac2 = ArrComparison(y, fit2, 'exponential') ## Create TaylorDiagram instance diagram = TaylorDiagram([ac1, ac2]) diagram.setup_ax(crmse_contour=True) diagram.plot(s=20) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.170 seconds) .. _sphx_glr_download_auto_examples_plot_taylor_diagram.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_taylor_diagram.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_taylor_diagram.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_taylor_diagram.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_