xarray-plotly 0.0.1__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.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: xarray_plotly
3
+ Version: 0.0.1
4
+ Summary: Interactive Plotly Express plotting accessor for xarray
5
+ Author: Felix
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/FBumann/xarray_plotly
8
+ Project-URL: Documentation, https://fbumann.github.io/xarray_plotly
9
+ Project-URL: Repository, https://github.com/FBumann/xarray_plotly
10
+ Keywords: xarray,plotly,visualization,interactive,plotting
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Visualization
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: xarray>=2023.1.0
25
+ Requires-Dist: plotly>=5.0.0
26
+ Requires-Dist: pandas>=1.5.0
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=7.0; extra == "dev"
29
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
30
+ Requires-Dist: mypy>=1.0; extra == "dev"
31
+ Requires-Dist: ruff>=0.4; extra == "dev"
32
+ Requires-Dist: pre-commit>=3.0; extra == "dev"
33
+ Requires-Dist: nbstripout>=0.6; extra == "dev"
34
+ Provides-Extra: docs
35
+ Requires-Dist: mkdocs>=1.5; extra == "docs"
36
+ Requires-Dist: mkdocs-material>=9.0; extra == "docs"
37
+ Requires-Dist: mkdocstrings[python]>=0.24; extra == "docs"
38
+ Requires-Dist: mkdocs-jupyter>=0.24; extra == "docs"
39
+ Requires-Dist: mkdocs-plotly-plugin>=0.1; extra == "docs"
40
+ Dynamic: license-file
41
+
42
+ # xarray_plotly
43
+
44
+ **Interactive Plotly Express plotting accessor for xarray**
45
+
46
+ [![PyPI version](https://badge.fury.io/py/xarray_plotly.svg)](https://badge.fury.io/py/xarray_plotly)
47
+ [![Python](https://img.shields.io/pypi/pyversions/xarray_plotly.svg)](https://pypi.org/project/xarray_plotly/)
48
+
49
+ xarray_plotly provides a `plotly` accessor for xarray DataArray objects that enables interactive plotting using Plotly Express with automatic dimension-to-slot assignment.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install xarray_plotly
55
+ ```
56
+
57
+ Or with uv:
58
+
59
+ ```bash
60
+ uv add xarray_plotly
61
+ ```
62
+
63
+ ## Quick Start
64
+
65
+ ```python
66
+ import xarray as xr
67
+ import numpy as np
68
+ from xarray_plotly import xpx
69
+
70
+ # Create sample data
71
+ da = xr.DataArray(
72
+ np.random.randn(100, 3, 2).cumsum(axis=0),
73
+ dims=["time", "city", "scenario"],
74
+ coords={
75
+ "time": np.arange(100),
76
+ "city": ["NYC", "LA", "Chicago"],
77
+ "scenario": ["baseline", "warming"],
78
+ },
79
+ name="temperature",
80
+ )
81
+
82
+ # Create an interactive line plot
83
+ # Dimensions auto-assign: time→x, city→color, scenario→facet_col
84
+ fig = xpx(da).line()
85
+ fig.show()
86
+
87
+ # Easy customization
88
+ fig.update_layout(title="Temperature Projections", template="plotly_dark")
89
+ ```
90
+
91
+ ## Usage Styles
92
+
93
+ xarray_plotly supports two equivalent usage styles:
94
+
95
+ ```python
96
+ # Function style (recommended) - full IDE code completion
97
+ from xarray_plotly import xpx
98
+ fig = xpx(da).line()
99
+
100
+ # Accessor style - works but no IDE completion
101
+ import xarray_plotly
102
+ fig = da.plotly.line()
103
+ ```
104
+
105
+ The `xpx()` function is recommended as it provides full IDE code completion and type hints.
106
+
107
+ **Why no IDE completion for the accessor?** xarray accessors are registered dynamically at runtime using `register_dataarray_accessor()`. Python's static type checkers and IDEs cannot see these dynamically added attributes, so `da.plotly` appears as an unknown attribute. This limitation could only be solved by xarray itself (e.g., through a type checker plugin), if at all. The `xpx()` function provides a workaround with an explicit return type that IDEs can follow.
108
+
109
+ ## Features
110
+
111
+ - **Interactive plots**: Zoom, pan, hover for values, toggle traces
112
+ - **Automatic dimension assignment**: Dimensions fill plot slots by position
113
+ - **Easy customization**: Returns Plotly `Figure` objects
114
+ - **Multiple plot types**: `line()`, `bar()`, `area()`, `scatter()`, `box()`, `imshow()`
115
+ - **Faceting and animation**: Built-in support for subplot grids and animations
116
+
117
+ ## Dimension Assignment
118
+
119
+ Dimensions are automatically assigned to plot "slots" based on their order:
120
+
121
+ ```python
122
+ # dims: (time, city, scenario)
123
+ # auto-assigns: time→x, city→color, scenario→facet_col
124
+ xpx(da).line()
125
+
126
+ # Override with explicit assignments
127
+ xpx(da).line(x="time", color="scenario", facet_col="city")
128
+
129
+ # Skip a slot with None
130
+ xpx(da).line(color=None) # time→x, city→facet_col
131
+ ```
132
+
133
+ ## Available Methods
134
+
135
+ | Method | Description | Slot Order |
136
+ |--------|-------------|------------|
137
+ | `line()` | Line plot | x → color → line_dash → symbol → facet_col → facet_row → animation_frame |
138
+ | `bar()` | Bar chart | x → color → pattern_shape → facet_col → facet_row → animation_frame |
139
+ | `area()` | Stacked area | x → color → pattern_shape → facet_col → facet_row → animation_frame |
140
+ | `scatter()` | Scatter plot | x → color → symbol → facet_col → facet_row → animation_frame |
141
+ | `box()` | Box plot | x → color → facet_col → facet_row → animation_frame |
142
+ | `imshow()` | Heatmap | y → x → facet_col → animation_frame |
143
+
144
+ ## Configuration
145
+
146
+ Customize label extraction and slot assignment behavior:
147
+
148
+ ```python
149
+ from xarray_plotly import config, xpx
150
+
151
+ # View current options
152
+ config.get_options()
153
+
154
+ # Set globally (temporary)
155
+ with config.set_options(label_include_units=False):
156
+ fig = xpx(da).line() # Labels won't include units
157
+ ```
158
+
159
+ **Available options:**
160
+
161
+ | Option | Default | Description |
162
+ |--------|---------|-------------|
163
+ | `label_use_long_name` | `True` | Use `long_name` attr for labels |
164
+ | `label_use_standard_name` | `True` | Fall back to `standard_name` |
165
+ | `label_include_units` | `True` | Append units to labels |
166
+ | `label_unit_format` | `"[{units}]"` | Format string for units |
167
+ | `slot_orders` | (defaults) | Slot orders per plot type |
168
+
169
+ ## Documentation
170
+
171
+ Full documentation with examples: [https://fbumann.github.io/xarray_plotly](https://fbumann.github.io/xarray_plotly)
172
+
173
+ ## License
174
+
175
+ MIT
@@ -0,0 +1,11 @@
1
+ xarray_plotly/__init__.py,sha256=P2Wfp0Iic2YecJlfDHtsZ6Rm0clpvkNyliei02lMjS4,1735
2
+ xarray_plotly/accessor.py,sha256=oYeA2WYsBe3iTXItqkEOk9aIZ0c7vQB1gjWkQcObU9M,10356
3
+ xarray_plotly/common.py,sha256=8kTa7wcwGqUIVpiEu0DpduxYnrYxamTNhFygT78xgC8,7077
4
+ xarray_plotly/config.py,sha256=JRd6JTQEIqe0bDs_jEUyVcdSMNmZBvNjwPlytywfn4I,6015
5
+ xarray_plotly/plotting.py,sha256=A8J3TIOtUhTGpyp8wk680wo3I8MVe0z_ZWnI67rkkbw,12393
6
+ xarray_plotly/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ xarray_plotly-0.0.1.dist-info/licenses/LICENSE,sha256=AvVEfNqbhIm9jHvt0acJNjW1JUKa2a70Zb5rJdEXCJI,1064
8
+ xarray_plotly-0.0.1.dist-info/METADATA,sha256=4qO64nUG0W2FTyQ8E6Ta5Iv6nIJIkWE0Egnqk29IxOs,6077
9
+ xarray_plotly-0.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ xarray_plotly-0.0.1.dist-info/top_level.txt,sha256=GtMkvuZvLAYTjYXtwoNUa0ag42CJARZJK1CZemYD7pg,14
11
+ xarray_plotly-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FBumann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ xarray_plotly