Interactive Taylor Diagram
This notebook shows usage examples of interactive Taylor Diagram. Detailed API description can be found here.
Import functions
[1]:
from bokeh.plotting import output_file, save, output_notebook
from ESMBenchmarkViz import taylor_diagram
[2]:
taylor_diagram
[2]:
<module 'ESMBenchmarkViz.taylor_diagram.taylor_diagram' from '/Users/lee1043/mambaforge/envs/pmp_devel_20241106_xcdat0.7.3/lib/python3.10/site-packages/ESMBenchmarkViz/taylor_diagram/taylor_diagram.py'>
[2]:
# Enable Bokeh output in the notebook
output_notebook()
1: Basic usage
Example 1 show basic usage of the function.
[3]:
# Sample data
std_devs = [0.3, 0.8, 1.2, 0.9, 1.1, 1.2, 1, 2]
correlations = [0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 1, 0.99]
names = ['Model A', 'Model B', 'Model C', 'Model D', 'Model E', 'Model F', 'Model G', 'Model H']
refstd = 1.25
# Figure settings
normalize = True # Set Trur or False
step = 0.2
# Plot
p = taylor_diagram(std_devs, correlations, names, refstd, normalize=normalize, step=step)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 12
9 step = 0.2
11 # Plot
---> 12 p = taylor_diagram(std_devs, correlations, names, refstd, normalize=normalize, step=step)
TypeError: 'module' object is not callable
2: More models with bigger figure size
Example 2 exapands to include more models in the plot.
[ ]:
std_devs = [0.3, 0.8, 1.2, 0.9, 1.1, 1.2, 1, 2, 1.3, 1.8, 2.2, 1.9, 2.1, 2.2, 2, 3]
correlations = [0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 1, 0.99, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 1, 0.99]
names = ['Model A', 'Model B', 'Model C', 'Model D', 'Model E', 'Model F', 'Model G', 'Model H', 'Model I', 'Model J', 'Model K', 'Model L', 'Model M', 'Model N', 'Model O', 'Model P']
refstd = 1.25
p = taylor_diagram(std_devs, correlations, names, refstd, normalize=normalize, step=step, colormap='magma_r', width=800)
3: Custom colors
Example 3 uses custom colors for data points.
[ ]:
std_devs = [0.8, 1.0, 1.2] # Standard deviations of models
correlations = [0.9, 0.85, 0.7] # Correlation coefficients
names = ["Model A", "Model B", "Model C"] # Names of models
refstd = 1.0 # Standard deviation of reference model
colormap = ["red", "green", "blue"] # Colors of models
taylor_diagram(std_devs, correlations, names, refstd, colormap=colormap)
4: Show diagnostic figures
Example 4 expands example 3 and generates an interactive Taylor Diagram where each data point is accompanied by a diagnostic figure that can be clicked on for more details.
[ ]:
std_devs = [0.8, 1.0, 1.2] # Standard deviations of models
correlations = [0.9, 0.85, 0.7] # Correlation coefficients
names = ["Model A", "Model B", "Model C"] # Names of models
refstd = 1.0 # Standard deviation of reference model
colormap = ["red", "green", "blue"] # Colors of models
images = [
'images/image1.jpg',
'images/image2.jpg',
'images/image3.jpg',
]
p = taylor_diagram(std_devs, correlations, names, refstd, colormap=colormap, images=images, width=500)
Save the plot
[ ]:
# set output to static HTML file
output_file(filename="interactive_taylor_diagram.html", title="Interactive Taylor Diagram")
# save the results to a file
save(p)
# Result: [`interactive_taylor_diagram.html`](interactive_taylor_diagram.html)