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

Mean clim patch #920

Merged
merged 19 commits into from
Apr 16, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add flexibility on vertical center line label
  • Loading branch information
lee1043 committed Apr 13, 2023
commit 4e21460a4c4cb9446303540e5ddd18573577ed9c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def parallel_coordinate_plot(
fill_between_lines_colors=("green", "red"),
vertical_center=None,
vertical_center_line=False,
vertical_center_line_label=None,
):
"""
Parameters
Expand Down Expand Up @@ -74,6 +75,7 @@ def parallel_coordinate_plot(
- `fill_between_lines_colors`: tuple or list containing two strings for colors filled between the two lines. Default=('green', 'red')
- `vertical_center`: string ("median", "mean")/float/integer, default=None, adjust range of vertical axis to set center of vertical axis as median, mean, or given number
- `vertical_center_line`: bool, default=False, show median as line
- `vertical_center_line_label`: str, default=None, label in legend for the horizontal vertical center line. If not given, it will be automatically assigned. It can be turned off by "off"

Return
------
Expand Down Expand Up @@ -227,8 +229,12 @@ def parallel_coordinate_plot(
clip_on=False,
)

if vertical_center_line:
ax.plot(range(N), zs_middle, "-", c="k", label="median", lw=1)
if vertical_center_line:
if vertical_center_line_label is None:
vertical_center_line_label = str(vertical_center)
elif vertical_center_line_label == "off":
vertical_center_line_label = None
ax.plot(range(N), zs_middle, "-", c="k", label=vertical_center_line_label, lw=1)

# Fill between lines
if fill_between_lines and (comparing_models is not None):
Expand Down Expand Up @@ -340,7 +346,10 @@ def _data_transform(
zs[:, 0] = ys[:, 0]
zs[:, 1:] = (ys[:, 1:] - ymins[1:]) / dys[1:] * dys[0] + ymins[0]

zs_middle = (ymids[:] - ymins[:]) / dys[:] * dys[0] + ymins[0]
if vertical_center is not None:
zs_middle = (ymids[:] - ymins[:]) / dys[:] * dys[0] + ymins[0]
else:
zs_middle = (ymaxs[:] - ymins[:]) / 2 / dys[:] * dys[0] + ymins[0]

if model_names2 is not None:
print("Models in the second group:", model_names2)
Expand Down