xarray-plotly 0.0.14__py3-none-any.whl → 0.0.17__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/__init__.py CHANGED
@@ -56,6 +56,9 @@ from xarray_plotly.common import SLOT_ORDERS, Colors, auto
56
56
  from xarray_plotly.figures import (
57
57
  add_secondary_y,
58
58
  overlay,
59
+ share_axis_labels,
60
+ simplify_facet_titles,
61
+ subplots,
59
62
  update_traces,
60
63
  )
61
64
 
@@ -66,6 +69,9 @@ __all__ = [
66
69
  "auto",
67
70
  "config",
68
71
  "overlay",
72
+ "share_axis_labels",
73
+ "simplify_facet_titles",
74
+ "subplots",
69
75
  "update_traces",
70
76
  "xpx",
71
77
  ]
xarray_plotly/accessor.py CHANGED
@@ -6,7 +6,7 @@ import plotly.graph_objects as go
6
6
  from xarray import DataArray, Dataset
7
7
 
8
8
  from xarray_plotly import plotting
9
- from xarray_plotly.common import Colors, SlotValue, auto
9
+ from xarray_plotly.common import Colors, FacetTitlesMode, SlotValue, auto
10
10
  from xarray_plotly.config import _options
11
11
 
12
12
 
@@ -54,6 +54,8 @@ class DataArrayPlotlyAccessor:
54
54
  facet_row: SlotValue = auto,
55
55
  animation_frame: SlotValue = auto,
56
56
  colors: Colors = None,
57
+ facet_titles: FacetTitlesMode = "default",
58
+ shared_axis_labels: bool = True,
57
59
  **px_kwargs: Any,
58
60
  ) -> go.Figure:
59
61
  """Create an interactive line plot.
@@ -69,6 +71,8 @@ class DataArrayPlotlyAccessor:
69
71
  facet_row: Dimension for subplot rows. Default: sixth dimension.
70
72
  animation_frame: Dimension for animation. Default: seventh dimension.
71
73
  colors: Color specification (scale name, list, or dict). See module docs.
74
+ shared_axis_labels: If True (default), repeated axis titles on faceted
75
+ plots are replaced with a single shared, centered label per axis.
72
76
  **px_kwargs: Additional arguments passed to `plotly.express.line()`.
73
77
 
74
78
  Returns:
@@ -84,6 +88,8 @@ class DataArrayPlotlyAccessor:
84
88
  facet_row=facet_row,
85
89
  animation_frame=animation_frame,
86
90
  colors=colors,
91
+ facet_titles=facet_titles,
92
+ shared_axis_labels=shared_axis_labels,
87
93
  **px_kwargs,
88
94
  )
89
95
 
@@ -97,6 +103,8 @@ class DataArrayPlotlyAccessor:
97
103
  facet_row: SlotValue = auto,
98
104
  animation_frame: SlotValue = auto,
99
105
  colors: Colors = None,
106
+ facet_titles: FacetTitlesMode = "default",
107
+ shared_axis_labels: bool = True,
100
108
  **px_kwargs: Any,
101
109
  ) -> go.Figure:
102
110
  """Create an interactive bar chart.
@@ -111,6 +119,8 @@ class DataArrayPlotlyAccessor:
111
119
  facet_row: Dimension for subplot rows. Default: fifth dimension.
112
120
  animation_frame: Dimension for animation. Default: sixth dimension.
113
121
  colors: Color specification (scale name, list, or dict). See module docs.
122
+ shared_axis_labels: If True (default), repeated axis titles on faceted
123
+ plots are replaced with a single shared, centered label per axis.
114
124
  **px_kwargs: Additional arguments passed to `plotly.express.bar()`.
115
125
 
116
126
  Returns:
@@ -125,6 +135,8 @@ class DataArrayPlotlyAccessor:
125
135
  facet_row=facet_row,
126
136
  animation_frame=animation_frame,
127
137
  colors=colors,
138
+ facet_titles=facet_titles,
139
+ shared_axis_labels=shared_axis_labels,
128
140
  **px_kwargs,
129
141
  )
130
142
 
@@ -138,6 +150,8 @@ class DataArrayPlotlyAccessor:
138
150
  facet_row: SlotValue = auto,
139
151
  animation_frame: SlotValue = auto,
140
152
  colors: Colors = None,
153
+ facet_titles: FacetTitlesMode = "default",
154
+ shared_axis_labels: bool = True,
141
155
  **px_kwargs: Any,
142
156
  ) -> go.Figure:
143
157
  """Create an interactive stacked area chart.
@@ -152,6 +166,8 @@ class DataArrayPlotlyAccessor:
152
166
  facet_row: Dimension for subplot rows. Default: fifth dimension.
153
167
  animation_frame: Dimension for animation. Default: sixth dimension.
154
168
  colors: Color specification (scale name, list, or dict). See module docs.
169
+ shared_axis_labels: If True (default), repeated axis titles on faceted
170
+ plots are replaced with a single shared, centered label per axis.
155
171
  **px_kwargs: Additional arguments passed to `plotly.express.area()`.
156
172
 
157
173
  Returns:
@@ -166,6 +182,8 @@ class DataArrayPlotlyAccessor:
166
182
  facet_row=facet_row,
167
183
  animation_frame=animation_frame,
168
184
  colors=colors,
185
+ facet_titles=facet_titles,
186
+ shared_axis_labels=shared_axis_labels,
169
187
  **px_kwargs,
170
188
  )
171
189
 
@@ -178,6 +196,8 @@ class DataArrayPlotlyAccessor:
178
196
  facet_row: SlotValue = auto,
179
197
  animation_frame: SlotValue = auto,
180
198
  colors: Colors = None,
199
+ facet_titles: FacetTitlesMode = "default",
200
+ shared_axis_labels: bool = True,
181
201
  **px_kwargs: Any,
182
202
  ) -> go.Figure:
183
203
  """Create a bar-like chart using stacked areas for better performance.
@@ -191,6 +211,8 @@ class DataArrayPlotlyAccessor:
191
211
  facet_row: Dimension for subplot rows. Default: fourth dimension.
192
212
  animation_frame: Dimension for animation. Default: fifth dimension.
193
213
  colors: Color specification (scale name, list, or dict). See module docs.
214
+ shared_axis_labels: If True (default), repeated axis titles on faceted
215
+ plots are replaced with a single shared, centered label per axis.
194
216
  **px_kwargs: Additional arguments passed to `plotly.express.area()`.
195
217
 
196
218
  Returns:
@@ -204,6 +226,8 @@ class DataArrayPlotlyAccessor:
204
226
  facet_row=facet_row,
205
227
  animation_frame=animation_frame,
206
228
  colors=colors,
229
+ facet_titles=facet_titles,
230
+ shared_axis_labels=shared_axis_labels,
207
231
  **px_kwargs,
208
232
  )
209
233
 
@@ -218,6 +242,8 @@ class DataArrayPlotlyAccessor:
218
242
  facet_row: SlotValue = auto,
219
243
  animation_frame: SlotValue = auto,
220
244
  colors: Colors = None,
245
+ facet_titles: FacetTitlesMode = "default",
246
+ shared_axis_labels: bool = True,
221
247
  **px_kwargs: Any,
222
248
  ) -> go.Figure:
223
249
  """Create an interactive scatter plot.
@@ -237,6 +263,8 @@ class DataArrayPlotlyAccessor:
237
263
  facet_row: Dimension for subplot rows. Default: fifth dimension.
238
264
  animation_frame: Dimension for animation. Default: sixth dimension.
239
265
  colors: Color specification (scale name, list, or dict). See module docs.
266
+ shared_axis_labels: If True (default), repeated axis titles on faceted
267
+ plots are replaced with a single shared, centered label per axis.
240
268
  **px_kwargs: Additional arguments passed to `plotly.express.scatter()`.
241
269
 
242
270
  Returns:
@@ -252,6 +280,8 @@ class DataArrayPlotlyAccessor:
252
280
  facet_row=facet_row,
253
281
  animation_frame=animation_frame,
254
282
  colors=colors,
283
+ facet_titles=facet_titles,
284
+ shared_axis_labels=shared_axis_labels,
255
285
  **px_kwargs,
256
286
  )
257
287
 
@@ -264,6 +294,8 @@ class DataArrayPlotlyAccessor:
264
294
  facet_row: SlotValue = None,
265
295
  animation_frame: SlotValue = None,
266
296
  colors: Colors = None,
297
+ facet_titles: FacetTitlesMode = "default",
298
+ shared_axis_labels: bool = True,
267
299
  **px_kwargs: Any,
268
300
  ) -> go.Figure:
269
301
  """Create an interactive box plot.
@@ -280,6 +312,8 @@ class DataArrayPlotlyAccessor:
280
312
  facet_row: Dimension for subplot rows. Default: None (aggregated).
281
313
  animation_frame: Dimension for animation. Default: None (aggregated).
282
314
  colors: Color specification (scale name, list, or dict). See module docs.
315
+ shared_axis_labels: If True (default), repeated axis titles on faceted
316
+ plots are replaced with a single shared, centered label per axis.
283
317
  **px_kwargs: Additional arguments passed to `plotly.express.box()`.
284
318
 
285
319
  Returns:
@@ -293,6 +327,8 @@ class DataArrayPlotlyAccessor:
293
327
  facet_row=facet_row,
294
328
  animation_frame=animation_frame,
295
329
  colors=colors,
330
+ facet_titles=facet_titles,
331
+ shared_axis_labels=shared_axis_labels,
296
332
  **px_kwargs,
297
333
  )
298
334
 
@@ -302,14 +338,17 @@ class DataArrayPlotlyAccessor:
302
338
  x: SlotValue = auto,
303
339
  y: SlotValue = auto,
304
340
  facet_col: SlotValue = auto,
341
+ facet_row: SlotValue = auto,
305
342
  animation_frame: SlotValue = auto,
306
343
  robust: bool = False,
307
344
  colors: Colors = None,
345
+ facet_titles: FacetTitlesMode = "default",
346
+ shared_axis_labels: bool = True,
308
347
  **px_kwargs: Any,
309
348
  ) -> go.Figure:
310
349
  """Create an interactive heatmap image.
311
350
 
312
- Slot order: y (rows) -> x (columns) -> facet_col -> animation_frame
351
+ Slot order: y (rows) -> x (columns) -> facet_col -> facet_row -> animation_frame
313
352
 
314
353
  Note:
315
354
  **Difference from px.imshow**: Color bounds are computed from the
@@ -320,9 +359,14 @@ class DataArrayPlotlyAccessor:
320
359
  x: Dimension for x-axis (columns). Default: second dimension.
321
360
  y: Dimension for y-axis (rows). Default: first dimension.
322
361
  facet_col: Dimension for subplot columns. Default: third dimension.
323
- animation_frame: Dimension for animation. Default: fourth dimension.
362
+ facet_row: Dimension for subplot rows. Default: fourth dimension.
363
+ Requires plotly>=6.7.0; on older versions this slot is skipped
364
+ during auto-assignment.
365
+ animation_frame: Dimension for animation. Default: fifth dimension.
324
366
  robust: If True, use 2nd/98th percentiles for color bounds (handles outliers).
325
367
  colors: Color scale name (e.g., "Viridis", "RdBu"). See module docs.
368
+ shared_axis_labels: If True (default), repeated axis titles on faceted
369
+ plots are replaced with a single shared, centered label per axis.
326
370
  **px_kwargs: Additional arguments passed to `plotly.express.imshow()`.
327
371
  Use `zmin` and `zmax` to manually set color scale bounds.
328
372
 
@@ -334,9 +378,12 @@ class DataArrayPlotlyAccessor:
334
378
  x=x,
335
379
  y=y,
336
380
  facet_col=facet_col,
381
+ facet_row=facet_row,
337
382
  animation_frame=animation_frame,
338
383
  robust=robust,
339
384
  colors=colors,
385
+ facet_titles=facet_titles,
386
+ shared_axis_labels=shared_axis_labels,
340
387
  **px_kwargs,
341
388
  )
342
389
 
@@ -348,6 +395,8 @@ class DataArrayPlotlyAccessor:
348
395
  facet_col: SlotValue = auto,
349
396
  facet_row: SlotValue = auto,
350
397
  colors: Colors = None,
398
+ facet_titles: FacetTitlesMode = "default",
399
+ shared_axis_labels: bool = True,
351
400
  **px_kwargs: Any,
352
401
  ) -> go.Figure:
353
402
  """Create an interactive pie chart.
@@ -360,6 +409,8 @@ class DataArrayPlotlyAccessor:
360
409
  facet_col: Dimension for subplot columns. Default: second dimension.
361
410
  facet_row: Dimension for subplot rows. Default: third dimension.
362
411
  colors: Color specification (scale name, list, or dict). See module docs.
412
+ shared_axis_labels: If True (default), repeated axis titles on faceted
413
+ plots are replaced with a single shared, centered label per axis.
363
414
  **px_kwargs: Additional arguments passed to `plotly.express.pie()`.
364
415
 
365
416
  Returns:
@@ -372,6 +423,8 @@ class DataArrayPlotlyAccessor:
372
423
  facet_col=facet_col,
373
424
  facet_row=facet_row,
374
425
  colors=colors,
426
+ facet_titles=facet_titles,
427
+ shared_axis_labels=shared_axis_labels,
375
428
  **px_kwargs,
376
429
  )
377
430
 
@@ -452,6 +505,8 @@ class DatasetPlotlyAccessor:
452
505
  facet_row: SlotValue = auto,
453
506
  animation_frame: SlotValue = auto,
454
507
  colors: Colors = None,
508
+ facet_titles: FacetTitlesMode = "default",
509
+ shared_axis_labels: bool = True,
455
510
  **px_kwargs: Any,
456
511
  ) -> go.Figure:
457
512
  """Create an interactive line plot.
@@ -466,6 +521,8 @@ class DatasetPlotlyAccessor:
466
521
  facet_row: Dimension for subplot rows.
467
522
  animation_frame: Dimension for animation.
468
523
  colors: Color specification (scale name, list, or dict). See module docs.
524
+ shared_axis_labels: If True (default), repeated axis titles on faceted
525
+ plots are replaced with a single shared, centered label per axis.
469
526
  **px_kwargs: Additional arguments passed to `plotly.express.line()`.
470
527
 
471
528
  Returns:
@@ -482,6 +539,8 @@ class DatasetPlotlyAccessor:
482
539
  facet_row=facet_row,
483
540
  animation_frame=animation_frame,
484
541
  colors=colors,
542
+ facet_titles=facet_titles,
543
+ shared_axis_labels=shared_axis_labels,
485
544
  **px_kwargs,
486
545
  )
487
546
 
@@ -496,6 +555,8 @@ class DatasetPlotlyAccessor:
496
555
  facet_row: SlotValue = auto,
497
556
  animation_frame: SlotValue = auto,
498
557
  colors: Colors = None,
558
+ facet_titles: FacetTitlesMode = "default",
559
+ shared_axis_labels: bool = True,
499
560
  **px_kwargs: Any,
500
561
  ) -> go.Figure:
501
562
  """Create an interactive bar chart.
@@ -509,6 +570,8 @@ class DatasetPlotlyAccessor:
509
570
  facet_row: Dimension for subplot rows.
510
571
  animation_frame: Dimension for animation.
511
572
  colors: Color specification (scale name, list, or dict). See module docs.
573
+ shared_axis_labels: If True (default), repeated axis titles on faceted
574
+ plots are replaced with a single shared, centered label per axis.
512
575
  **px_kwargs: Additional arguments passed to `plotly.express.bar()`.
513
576
 
514
577
  Returns:
@@ -524,6 +587,8 @@ class DatasetPlotlyAccessor:
524
587
  facet_row=facet_row,
525
588
  animation_frame=animation_frame,
526
589
  colors=colors,
590
+ facet_titles=facet_titles,
591
+ shared_axis_labels=shared_axis_labels,
527
592
  **px_kwargs,
528
593
  )
529
594
 
@@ -538,6 +603,8 @@ class DatasetPlotlyAccessor:
538
603
  facet_row: SlotValue = auto,
539
604
  animation_frame: SlotValue = auto,
540
605
  colors: Colors = None,
606
+ facet_titles: FacetTitlesMode = "default",
607
+ shared_axis_labels: bool = True,
541
608
  **px_kwargs: Any,
542
609
  ) -> go.Figure:
543
610
  """Create an interactive stacked area chart.
@@ -551,6 +618,8 @@ class DatasetPlotlyAccessor:
551
618
  facet_row: Dimension for subplot rows.
552
619
  animation_frame: Dimension for animation.
553
620
  colors: Color specification (scale name, list, or dict). See module docs.
621
+ shared_axis_labels: If True (default), repeated axis titles on faceted
622
+ plots are replaced with a single shared, centered label per axis.
554
623
  **px_kwargs: Additional arguments passed to `plotly.express.area()`.
555
624
 
556
625
  Returns:
@@ -566,6 +635,8 @@ class DatasetPlotlyAccessor:
566
635
  facet_row=facet_row,
567
636
  animation_frame=animation_frame,
568
637
  colors=colors,
638
+ facet_titles=facet_titles,
639
+ shared_axis_labels=shared_axis_labels,
569
640
  **px_kwargs,
570
641
  )
571
642
 
@@ -579,6 +650,8 @@ class DatasetPlotlyAccessor:
579
650
  facet_row: SlotValue = auto,
580
651
  animation_frame: SlotValue = auto,
581
652
  colors: Colors = None,
653
+ facet_titles: FacetTitlesMode = "default",
654
+ shared_axis_labels: bool = True,
582
655
  **px_kwargs: Any,
583
656
  ) -> go.Figure:
584
657
  """Create a bar-like chart using stacked areas for better performance.
@@ -591,6 +664,8 @@ class DatasetPlotlyAccessor:
591
664
  facet_row: Dimension for subplot rows.
592
665
  animation_frame: Dimension for animation.
593
666
  colors: Color specification (scale name, list, or dict). See module docs.
667
+ shared_axis_labels: If True (default), repeated axis titles on faceted
668
+ plots are replaced with a single shared, centered label per axis.
594
669
  **px_kwargs: Additional arguments passed to `plotly.express.area()`.
595
670
 
596
671
  Returns:
@@ -605,6 +680,8 @@ class DatasetPlotlyAccessor:
605
680
  facet_row=facet_row,
606
681
  animation_frame=animation_frame,
607
682
  colors=colors,
683
+ facet_titles=facet_titles,
684
+ shared_axis_labels=shared_axis_labels,
608
685
  **px_kwargs,
609
686
  )
610
687
 
@@ -620,6 +697,8 @@ class DatasetPlotlyAccessor:
620
697
  facet_row: SlotValue = auto,
621
698
  animation_frame: SlotValue = auto,
622
699
  colors: Colors = None,
700
+ facet_titles: FacetTitlesMode = "default",
701
+ shared_axis_labels: bool = True,
623
702
  **px_kwargs: Any,
624
703
  ) -> go.Figure:
625
704
  """Create an interactive scatter plot.
@@ -634,6 +713,8 @@ class DatasetPlotlyAccessor:
634
713
  facet_row: Dimension for subplot rows.
635
714
  animation_frame: Dimension for animation.
636
715
  colors: Color specification (scale name, list, or dict). See module docs.
716
+ shared_axis_labels: If True (default), repeated axis titles on faceted
717
+ plots are replaced with a single shared, centered label per axis.
637
718
  **px_kwargs: Additional arguments passed to `plotly.express.scatter()`.
638
719
 
639
720
  Returns:
@@ -650,6 +731,8 @@ class DatasetPlotlyAccessor:
650
731
  facet_row=facet_row,
651
732
  animation_frame=animation_frame,
652
733
  colors=colors,
734
+ facet_titles=facet_titles,
735
+ shared_axis_labels=shared_axis_labels,
653
736
  **px_kwargs,
654
737
  )
655
738
 
@@ -663,6 +746,8 @@ class DatasetPlotlyAccessor:
663
746
  facet_row: SlotValue = None,
664
747
  animation_frame: SlotValue = None,
665
748
  colors: Colors = None,
749
+ facet_titles: FacetTitlesMode = "default",
750
+ shared_axis_labels: bool = True,
666
751
  **px_kwargs: Any,
667
752
  ) -> go.Figure:
668
753
  """Create an interactive box plot.
@@ -675,6 +760,8 @@ class DatasetPlotlyAccessor:
675
760
  facet_row: Dimension for subplot rows.
676
761
  animation_frame: Dimension for animation.
677
762
  colors: Color specification (scale name, list, or dict). See module docs.
763
+ shared_axis_labels: If True (default), repeated axis titles on faceted
764
+ plots are replaced with a single shared, centered label per axis.
678
765
  **px_kwargs: Additional arguments passed to `plotly.express.box()`.
679
766
 
680
767
  Returns:
@@ -689,6 +776,8 @@ class DatasetPlotlyAccessor:
689
776
  facet_row=facet_row,
690
777
  animation_frame=animation_frame,
691
778
  colors=colors,
779
+ facet_titles=facet_titles,
780
+ shared_axis_labels=shared_axis_labels,
692
781
  **px_kwargs,
693
782
  )
694
783
 
@@ -701,6 +790,8 @@ class DatasetPlotlyAccessor:
701
790
  facet_col: SlotValue = auto,
702
791
  facet_row: SlotValue = auto,
703
792
  colors: Colors = None,
793
+ facet_titles: FacetTitlesMode = "default",
794
+ shared_axis_labels: bool = True,
704
795
  **px_kwargs: Any,
705
796
  ) -> go.Figure:
706
797
  """Create an interactive pie chart.
@@ -712,6 +803,8 @@ class DatasetPlotlyAccessor:
712
803
  facet_col: Dimension for subplot columns.
713
804
  facet_row: Dimension for subplot rows.
714
805
  colors: Color specification (scale name, list, or dict). See module docs.
806
+ shared_axis_labels: If True (default), repeated axis titles on faceted
807
+ plots are replaced with a single shared, centered label per axis.
715
808
  **px_kwargs: Additional arguments passed to `plotly.express.pie()`.
716
809
 
717
810
  Returns:
@@ -725,5 +818,7 @@ class DatasetPlotlyAccessor:
725
818
  facet_col=facet_col,
726
819
  facet_row=facet_row,
727
820
  colors=colors,
821
+ facet_titles=facet_titles,
822
+ shared_axis_labels=shared_axis_labels,
728
823
  **px_kwargs,
729
824
  )
xarray_plotly/common.py CHANGED
@@ -5,7 +5,7 @@ from __future__ import annotations
5
5
  import functools
6
6
  import warnings
7
7
  from collections.abc import Hashable, Mapping, Sequence
8
- from typing import TYPE_CHECKING, Any
8
+ from typing import TYPE_CHECKING, Any, Literal
9
9
 
10
10
  import plotly.express as px
11
11
 
@@ -39,6 +39,13 @@ Colors = str | Sequence[str] | Mapping[str, str] | None
39
39
  - None: Use Plotly defaults
40
40
  """
41
41
 
42
+ FacetTitlesMode = Literal["value", "default"]
43
+ """Type alias for facet_titles parameter.
44
+
45
+ - "default" (default): keep PX's ``"<dim>=<value>"`` subplot titles.
46
+ - "value": strip the ``<dim>=`` prefix, leaving just the value.
47
+ """
48
+
42
49
  # Re-export for backward compatibility
43
50
  SLOT_ORDERS = DEFAULT_SLOT_ORDERS
44
51
  """Slot orders per plot type.
xarray_plotly/config.py CHANGED
@@ -43,7 +43,7 @@ DEFAULT_SLOT_ORDERS: dict[str, tuple[str, ...]] = {
43
43
  "facet_row",
44
44
  "animation_frame",
45
45
  ),
46
- "imshow": ("y", "x", "facet_col", "animation_frame"),
46
+ "imshow": ("y", "x", "facet_col", "facet_row", "animation_frame"),
47
47
  "box": ("x", "color", "facet_col", "facet_row", "animation_frame"),
48
48
  "pie": ("names", "facet_col", "facet_row"),
49
49
  }