From e7490026c1d619535d21ee54a074f74e8e657f01 Mon Sep 17 00:00:00 2001 From: Jiwoo Lee Date: Thu, 24 Aug 2023 20:51:06 -0700 Subject: [PATCH] add capability to overwrite labels of highlighted models --- .../parallel_coordinate_plot_lib.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pcmdi_metrics/graphics/parallel_coordinate_plot/parallel_coordinate_plot_lib.py b/pcmdi_metrics/graphics/parallel_coordinate_plot/parallel_coordinate_plot_lib.py index a76496a39..a629c602a 100644 --- a/pcmdi_metrics/graphics/parallel_coordinate_plot/parallel_coordinate_plot_lib.py +++ b/pcmdi_metrics/graphics/parallel_coordinate_plot/parallel_coordinate_plot_lib.py @@ -16,6 +16,7 @@ def parallel_coordinate_plot( model_names, models_to_highlight=list(), models_to_highlight_colors=None, + models_to_highlight_labels=None, fig=None, ax=None, figsize=(15, 5), @@ -51,6 +52,7 @@ def parallel_coordinate_plot( - `model_names`: list, name of models for markers/lines (axis=0) - `models_to_highlight`: list, default=None, List of models to highlight as lines - `models_to_highlight_colors`: list, default=None, List of colors for models to highlight as lines + - `models_to_highlight_labels`: list, default=None, List of string labels for models to highlight as lines - `fig`: `matplotlib.figure` instance to which the parallel coordinate plot is plotted. If not provided, use current axes or create a new one. Optional. - `ax`: `matplotlib.axes.Axes` instance to which the parallel coordinate plot is plotted. @@ -222,7 +224,13 @@ def parallel_coordinate_plot( color = models_to_highlight_colors[mh_index] else: color = colors[j] - ax.plot(range(N), zs[j, :], "-", c=color, label=model, lw=3) + + if models_to_highlight_labels is not None: + label = models_to_highlight_labels[mh_index] + else: + label = model + + ax.plot(range(N), zs[j, :], "-", c=color, label=label, lw=3) mh_index += 1 else: if identify_all_models: