Interactive Plotly Express plotting for xarray
pip install xarray_plotlyimport xarray as xr
import numpy as np
import xarray_plotly # registers the accessor
da = xr.DataArray(
np.random.randn(100, 3).cumsum(axis=0),
dims=["time", "city"],
coords={"time": np.arange(100), "city": ["NYC", "LA", "Chicago"]},
)
# Accessor style
fig = da.plotly.line()
fig.show()
# Or with xpx() for IDE code completion
from xarray_plotly import xpx
fig = xpx(da).line()Why xpx()? The accessor (da.plotly) works but IDEs can't provide code completion for it. This is because xarray accessors are registered dynamically at runtime, making them invisible to static type checkers. The xpx() function provides the same functionality with full IDE support. This limitation could only be solved by xarray itself, if at all — it may be a fundamental Python limitation.
Full documentation: https://fbumann.github.io/xarray_plotly
MIT