xarray-plotly 0.0.12__py3-none-any.whl → 0.0.13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
xarray_plotly/figures.py CHANGED
@@ -308,6 +308,13 @@ def add_secondary_y(
308
308
  # Build mapping from primary y-axes to secondary y-axes
309
309
  y_mapping = _build_secondary_y_mapping(base_axes)
310
310
 
311
+ # Build x-y correspondence from base_axes (which x-axis pairs with which y-axis)
312
+ x_for_y = {yaxis: xaxis for xaxis, yaxis in base_axes}
313
+
314
+ # Find the rightmost x-axis (highest number) to determine which secondary axis shows ticks
315
+ rightmost_x = max(x_for_y.values(), key=lambda x: int(x[1:]) if x != "x" else 1)
316
+ rightmost_primary_y = next(y for y, x in x_for_y.items() if x == rightmost_x)
317
+
311
318
  # Create new figure with base's layout
312
319
  combined = go.Figure(layout=copy.deepcopy(base.layout))
313
320
 
@@ -322,24 +329,32 @@ def add_secondary_y(
322
329
  trace_copy.yaxis = y_mapping[original_yaxis]
323
330
  combined.add_trace(trace_copy)
324
331
 
332
+ # Get the rightmost secondary y-axis name for linking
333
+ rightmost_secondary_y = y_mapping[rightmost_primary_y]
334
+
325
335
  # Configure secondary y-axes
326
336
  for primary_yaxis, secondary_yaxis in y_mapping.items():
327
- # Get title - only set on first secondary axis or use provided title
337
+ is_rightmost = primary_yaxis == rightmost_primary_y
338
+
339
+ # Get title - only set on rightmost secondary axis
328
340
  title = None
329
- if secondary_y_title is not None:
330
- # Only set title on the first secondary axis to avoid repetition
331
- if primary_yaxis == "y":
341
+ if is_rightmost:
342
+ if secondary_y_title is not None:
332
343
  title = secondary_y_title
333
- elif primary_yaxis == "y" and secondary.layout.yaxis and secondary.layout.yaxis.title:
334
- # Try to get from secondary's layout
335
- title = secondary.layout.yaxis.title.text
344
+ elif secondary.layout.yaxis and secondary.layout.yaxis.title:
345
+ title = secondary.layout.yaxis.title.text
336
346
 
337
347
  # Configure the secondary axis
348
+ # Anchor to the corresponding x-axis so it appears on the right side of its subplot
338
349
  axis_config = {
339
350
  "title": title,
340
351
  "overlaying": primary_yaxis,
341
352
  "side": "right",
342
- "anchor": "free" if primary_yaxis != "y" else None,
353
+ "anchor": x_for_y[primary_yaxis],
354
+ # Only show ticks on the rightmost secondary axis
355
+ "showticklabels": is_rightmost,
356
+ # Link non-rightmost axes to the rightmost for consistent scaling
357
+ "matches": None if is_rightmost else rightmost_secondary_y,
343
358
  }
344
359
  # Remove None values
345
360
  axis_config = {k: v for k, v in axis_config.items() if v is not None}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xarray_plotly
3
- Version: 0.0.12
3
+ Version: 0.0.13
4
4
  Summary: Interactive Plotly Express plotting accessor for xarray
5
5
  Author: Felix
6
6
  License: MIT
@@ -84,6 +84,25 @@ fig = xpx(da).line()
84
84
 
85
85
  Full documentation: [https://fbumann.github.io/xarray_plotly](https://fbumann.github.io/xarray_plotly)
86
86
 
87
+ ## Roadmap
88
+
89
+ Planned additions (contributions welcome):
90
+
91
+ **New plot types**
92
+ - `histogram()` — distribution of DataArray values
93
+ - `violin()` — richer distribution visualization than box plots
94
+ - `density_heatmap()` — 2D histograms (x and y as dimensions)
95
+ - `density_contour()` — 2D density contours (x and y as dimensions)
96
+
97
+ **Enhancements**
98
+ - WebGL rendering option for `line()` and `scatter()` (large datasets)
99
+
100
+ **Figure utilities** (facet/animation-aware)
101
+ - `fill_between()` — fill area between two traces (uncertainty bands)
102
+ - `sync_axes()` — consistent axis ranges across facets and animation frames
103
+ - `add_secondary_x()` — secondary x-axis (like `add_secondary_y()`)
104
+ - `stack()` — vertically stack separate figures into subplots
105
+
87
106
  ## License
88
107
 
89
108
  MIT
@@ -2,11 +2,11 @@ xarray_plotly/__init__.py,sha256=8YaSdbzAakzlRqkq9HkQlMxWOLGg2JfUN-gAkyCGf5U,347
2
2
  xarray_plotly/accessor.py,sha256=XsGREdfGGqzFzpM53AzTbMnCOEtZTv0Sau-dc15meHQ,25313
3
3
  xarray_plotly/common.py,sha256=XN5qDYG1UOGuocNekckujJNyDbWA9Q7pvdx8hC6w7OA,9576
4
4
  xarray_plotly/config.py,sha256=fOL7cqPHVj_XNLqN1oT2KQZ0DitIjzeYnWyMKcJy0cc,6679
5
- xarray_plotly/figures.py,sha256=kfTPkIpT0683XHBH-RuuM5cvuA_IzChDRcCSjOC0QEc,15709
5
+ xarray_plotly/figures.py,sha256=uKC_8kcoFJYXsqMu-QRAsKfY8O_E3r8McBfRiHZxciE,16457
6
6
  xarray_plotly/plotting.py,sha256=qHoEU1NX-YWkI23G60xYg_gzR_fEBSDcdrg0B2NpoPs,24106
7
7
  xarray_plotly/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- xarray_plotly-0.0.12.dist-info/licenses/LICENSE,sha256=AvVEfNqbhIm9jHvt0acJNjW1JUKa2a70Zb5rJdEXCJI,1064
9
- xarray_plotly-0.0.12.dist-info/METADATA,sha256=3f-FDiVVKjJOt2GpbYC0mr0Q5F2tNPSNVPvWA7ejRRY,3416
10
- xarray_plotly-0.0.12.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
11
- xarray_plotly-0.0.12.dist-info/top_level.txt,sha256=GtMkvuZvLAYTjYXtwoNUa0ag42CJARZJK1CZemYD7pg,14
12
- xarray_plotly-0.0.12.dist-info/RECORD,,
8
+ xarray_plotly-0.0.13.dist-info/licenses/LICENSE,sha256=AvVEfNqbhIm9jHvt0acJNjW1JUKa2a70Zb5rJdEXCJI,1064
9
+ xarray_plotly-0.0.13.dist-info/METADATA,sha256=nDhnBWFgNvJNHIJ943a_prVAsGXyqZFHHspsmsRJJPg,4164
10
+ xarray_plotly-0.0.13.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
11
+ xarray_plotly-0.0.13.dist-info/top_level.txt,sha256=GtMkvuZvLAYTjYXtwoNUa0ag42CJARZJK1CZemYD7pg,14
12
+ xarray_plotly-0.0.13.dist-info/RECORD,,