Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Taylor Diagram function #874

Merged
merged 17 commits into from
Oct 12, 2022
Merged
Prev Previous commit
Next Next commit
enable mutli-panel plot
  • Loading branch information
lee1043 committed Sep 27, 2022
commit eb69b5b60ad3a0b695d83fe1e7766c2d539454cc
36 changes: 28 additions & 8 deletions pcmdi_metrics/graphics/taylor_diagram/taylor_diagram.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
def TaylorDiagram(
stddev, corrcoef, refstd,
fig=None,
rect=111,
title=None,
colors=None,
cmap=None,
normalize=False,
labels=None, markers=None, markersizes=None, zorders=None,
ref_label=None, smax=None,
labels=None,
markers=None,
markersizes=None,
zorders=None,
ref_label=None,
smax=None,
compare_models=None,
arrowprops_dict=None,
annotate_text=None,
radial_axis_title=None,
angular_axis_title=None):

"""Plot a Taylor diagram

Jiwoo Lee (PCMDI LLNL) - last update: September 2022

This code was adpated from the ILAMB code that was written by Nathan Collier (ORNL)
(https://github.com/rubisco-sfa/ILAMB/blob/master/src/ILAMB/Post.py#L80)
and revised by Jiwoo Lee (LLNL) to implement into PMP and to enable more customizations.
and revised by Jiwoo Lee (LLNL) to add capabilities and enable more customizations
for implementation into PCMDI Metrics Package (PMP).
The original code was written by Yannick Copin (https://gist.github.com/ycopin/3342888)

Reference for Taylor Diagram:
Taylor, K. E. (2001), Summarizing multiple aspects of model performance in a single diagram,
J. Geophys. Res., 106(D7), 7183–7192, http:https://dx.doi.org/10.1029/2000JD900719

The original code was written by Yannick Copin:
https://gist.github.com/ycopin/3342888

Parameters
----------
Expand All @@ -31,6 +43,12 @@ def TaylorDiagram(
the reference standard deviation
fig : matplotlib figure, optional
the matplotlib figure
rect : a 3-digit integer, optional
ax subplot rect, , default is 111, which indicate the figure has 1 row, 1 column, and this plot is the first plot.
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplot.html
https://matplotlib.org/stable/api/figure_api.html#matplotlib.figure.Figure.add_subplot
title : string, optional
title for the plot
cmap : string, optional
a name of matplotlib colormap
https://matplotlib.org/stable/gallery/color/colormap_reference.html
Expand Down Expand Up @@ -92,6 +110,8 @@ def TaylorDiagram(
if normalize:
stddev = stddev / refstd
refstd = 1.

# Radial axis range
smin = 0
if smax is None:
smax = max(2.0, 1.1 * stddev.max())
Expand All @@ -104,9 +124,9 @@ def TaylorDiagram(

if fig is None:
fig = plt.figure(figsize=(8, 8))

ax = FA.FloatingSubplot(fig, 111, grid_helper=ghelper)
fig.add_subplot(ax)
ax = fig.add_subplot(
rect, axes_class=FA.FloatingAxes, grid_helper=ghelper, title=title)

if colors is None:
if cmap is None:
Expand Down
107 changes: 101 additions & 6 deletions pcmdi_metrics/graphics/taylor_diagram/taylor_diagram_example.ipynb

Large diffs are not rendered by default.