Skip to content

Commit 6967ef5

Browse files
committed
fix: secondary yaxis matching
1 parent 3c75f1f commit 6967ef5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

xarray_plotly/figures.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ def add_secondary_y(
329329
trace_copy.yaxis = y_mapping[original_yaxis]
330330
combined.add_trace(trace_copy)
331331

332+
# Get the rightmost secondary y-axis name for linking
333+
rightmost_secondary_y = y_mapping[rightmost_primary_y]
334+
332335
# Configure secondary y-axes
333336
for primary_yaxis, secondary_yaxis in y_mapping.items():
334337
is_rightmost = primary_yaxis == rightmost_primary_y
@@ -350,6 +353,8 @@ def add_secondary_y(
350353
"anchor": x_for_y[primary_yaxis],
351354
# Only show ticks on the rightmost secondary axis
352355
"showticklabels": is_rightmost,
356+
# Link non-rightmost axes to the rightmost for consistent scaling
357+
"matches": None if is_rightmost else rightmost_secondary_y,
353358
}
354359
# Remove None values
355360
axis_config = {k: v for k, v in axis_config.items() if v is not None}

0 commit comments

Comments
 (0)