Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion HOW_TO_RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ upstream https://github.com/pydata/xarray (push)
Then run

```sh
pixi run release-contributors
pixi run -e release release-contributors
```

and copy the output.
Expand Down
1 change: 1 addition & 0 deletions doc/api-hidden.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@
plot.imshow
plot.pcolormesh
plot.scatter
plot.lines
plot.surface

CFTimeIndex.all
Expand Down
2 changes: 2 additions & 0 deletions doc/api/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Dataset
:toctree: ../generated/
:template: autosummary/accessor_method.rst

Dataset.plot.lines
Dataset.plot.scatter
Dataset.plot.quiver
Dataset.plot.streamplot
Expand All @@ -32,6 +33,7 @@ DataArray
DataArray.plot.hist
DataArray.plot.imshow
DataArray.plot.line
DataArray.plot.lines
DataArray.plot.pcolormesh
DataArray.plot.step
DataArray.plot.scatter
Expand Down
29 changes: 29 additions & 0 deletions doc/user-guide/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,35 @@ ds.to_zarr(
The number of chunks on Tair matches our dask chunks, while there is now only a single
chunk in the directory stores of each coordinate.

(io.zarr.rectilinear-chunks)=

### Variable-sized (rectilinear) chunks

Zarr v3 supports _rectilinear_ chunk grids, where chunk sizes vary along one
or more dimensions. This is useful when natural data boundaries (yearly
chunks of a daily time series, per-tile spatial extents) don't align to a
regular grid. Reading such arrays requires `zarr-python >= 3.2`, with the
experimental feature enabled:

```python
import zarr

with zarr.config.set({"array.rectilinear_chunks": True}):
roundtrip = xr.open_zarr("rectilinear.zarr", zarr_format=3)
roundtrip.chunks["x"] # e.g. (10, 20, 30)
```

```{note}
xarray can currently only *read* rectilinear-chunked Zarr V3 arrays, not
write them. Rectilinear arrays must be created with `zarr-python` directly
(or another tool, such as Icechunk) before being opened with `xr.open_zarr`.
This also means a Dataset opened from a rectilinear-chunked store cannot be
written back with {py:meth}`Dataset.to_zarr`, including writing to a
`region` of the store -- both raise a `TypeError` naming the affected
variable. Write support is tracked in
[GH11279](https://github.com/pydata/xarray/pull/11279).
```

### Groups

Nested groups in zarr stores can be represented by loading the store as a
Expand Down
53 changes: 53 additions & 0 deletions doc/user-guide/plotting.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,59 @@ ds.plot.scatter(x="A", y="B", z="z", hue="y", markersize="x", row="x", col="w");
For more advanced scatter plots, we recommend converting the relevant data variables
to a pandas DataFrame and using the extensive plotting capabilities of `seaborn`.

### Lines

{py:func}`xarray.plot.lines` calls matplotlib.collections.LineCollection under the hood,
allowing multiple lines being drawn efficiently. It uses similar arguments as
{py:func}`xarray.plot.scatter`.

Let's return to the air temperature dataset:

```{code-cell}
airtemps = xr.tutorial.open_dataset("air_temperature")
air = airtemps.air - 273.15
air.attrs = airtemps.air.attrs
air.attrs["units"] = "deg C"

air.isel(lon=10).plot.lines(x="time", hue="lat");
```

Make it a little more transparent:

```{code-cell}
air.isel(lon=10).plot.lines(x="time", hue="lat", alpha=0.2);
```

Zoom in a little on the x-axis, and compare a few latitudes and longitudes,
group them using `hue` and `linewidth`. The `linewidth` kwarg works in
a similar way as `markersize` kwarg for scatter plots, it lets you vary the
line's size by variable value.

```{code-cell}
:tags: [remove-stderr]

air_zoom = air.isel(time=slice(1200, 1500), lat=[5, 10, 15], lon=[10, 15])
air_zoom.plot.lines(x="time", hue="lat", linewidth="lon", add_colorbar=False);
```

Lines can modify the linestyle but does not allow markers. Instead combine {py:func}`xarray.plot.lines`
with {py:func}`xarray.plot.scatter`:

```{code-cell}
air.isel(lat=10, lon=10)[:200].plot.lines(x="time", color="k", linestyle="dashed")
air.isel(lat=10, lon=10)[:200].plot.scatter(x="time", color="k", marker="^");
```

Switching to another dataset with more variables we can analyse in similar
fashion as {py:func}`xarray.plot.scatter`:

```{code-cell}
:tags: [remove-stderr]

ds = xr.tutorial.scatter_example_dataset(seed=42)
ds.plot.lines(x="A", y="B", hue="y", linewidth="x", row="x", col="w");
```

### Quiver

Visualizing vector fields is supported with quiver plots:
Expand Down
Loading
Loading