Skip to content

FBumann/xarray_plotly

Repository files navigation

xarray_plotly

Interactive Plotly Express plotting for xarray

PyPI version Python CI Docs License: MIT

Installation

pip install xarray_plotly

Quick Start

import 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.

Documentation

Full documentation: https://fbumann.github.io/xarray_plotly

Roadmap

Planned additions (contributions welcome):

New plot types

  • histogram() — distribution of DataArray values
  • violin() — richer distribution visualization than box plots
  • density_heatmap() — 2D histograms (x and y as dimensions)
  • density_contour() — 2D density contours (x and y as dimensions)

Enhancements

  • WebGL rendering option for line() and scatter() (large datasets)

Figure utilities (facet/animation-aware)

  • fill_between() — fill area between two traces (uncertainty bands)
  • sync_axes() — consistent axis ranges across facets and animation frames
  • add_secondary_x() — secondary x-axis (like add_secondary_y())
  • stack() — vertically stack separate figures into subplots

License

MIT

About

Convenience plotting accessor for xarray binding to plotly express

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages