Skip to content

hue argument for xarray.plot.step() for plotting multiple histograms over shared bins #4288

Open
@jaicher

Description

@jaicher

Is your feature request related to a problem? Please describe.

I love how efficiently we can plot line data for different observations using xr.DataArray.plot(hue={hue coordinate name}) over a 2D array, and I have appreciated xr.DataArray.plot.step() for plotting histogram data using interval coordinates. Today, I wanted to plot/compare several histograms over the same set of bins. I figured I could write xr.DataArray.plot.step(hue={...}), but I found out that this functionality is not implemented.

Describe the solution you'd like

I think we should have a hue kwarg for xr.DataArray.plot.step(). When specified, we would be able to plot 2D data in the same way as xr.DataArray.plot(), except that we get a set of step plots instead of a set of line plots.

Describe alternatives you've considered

  • Use xr.DataArray.plot() instead. This is effective for histograms with many bins, but inaccurately represents histograms with coarse bins
  • Manually call xr.DataArray.plot.hist() on each 1D subarray for each label on the hue coordinate, adding appropriate labels and legend. This is fine and my current solution, but I think it would be excellent to use the same shorthand that was developed for line plots.

Additional context

I didn't evaluate the other plotting functions implemented, but I suspect that others could appropriately consider a hue argument but do not yet support doing so.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions