Customise Taylor Diagram#

This examples shows hot to plot multiple model results in one figure

For simplicity, we separate different variables of the sample model into two lists and we pretend that they are two models.

plot model comparisons taylordiagram
/home/docs/checkouts/readthedocs.org/user_builds/cgeniepy/envs/latest/lib/python3.12/site-packages/cgeniepy/model.py:58: UserWarning: No gemflag is provided, use default gemflags: [biogem]
  warnings.warn("No gemflag is provided, use default gemflags: [biogem]")
/home/docs/checkouts/readthedocs.org/user_builds/cgeniepy/envs/latest/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)

import matplotlib.pyplot as plt

import cgeniepy
from cgeniepy.skill import ArrComparison, TaylorDiagram

sample_model = cgeniepy.sample_model()
bgc_data = cgeniepy.load_obs('worjh2')

genie_var  = ['ocn_O2', 'ocn_ALK','ocn_PO4', 'ocn_temp', 'ocn_sal', 'ocn_SiO2', 'ocn_DIC']
obs_var = ['o2', 'alk', 'po4', 'temp', 'sal', 'si', 'dic']

arr_comps = []
for x,y in zip(genie_var, obs_var):
    obs = bgc_data[y]
    model = sample_model.get_var(x).isel(time=-1)
    tmp = ArrComparison(model.data.to_numpy(), obs.to_numpy(), label=y)
    arr_comps.append(tmp)

# you can set the figure size and dpi here
fig = plt.figure(dpi=200,figsize=(4,4))

# Assume this your first model
td = TaylorDiagram(arr_comps[:3])
td.setup_ax(crmse_contour=True,fig=fig)
td.plot(s=100, cmap=plt.get_cmap('tab10',3))

# Assume this your second model
td.ac = arr_comps[3:6]
td.extract_data() # refresh the data
td.plot(s=100, cmap=plt.get_cmap('tab10',3),linestyle='--')

plt.show()

Total running time of the script: (0 minutes 0.259 seconds)

Gallery generated by Sphinx-Gallery