easyclimate.plot.bar

Bar plot for xarray dataset

Functions

bar_plot_with_threshold(...)

Plot a bar chart with time for a 1D xarray.DataArray with bars colored based on a threshold value.

Module Contents

easyclimate.plot.bar.bar_plot_with_threshold(da: xarray.DataArray, width=0.8, threshold: float = 0, pos_color: str = 'red', neg_color: str = 'blue', ax=None, **kwargs) matplotlib.container.BarContainer

Plot a bar chart with time for a 1D xarray.DataArray with bars colored based on a threshold value.

Parameters:

daxarray.DataArray

1-dimensional data array to plot

width: float or array-like, default: 0.8

The width(s) of the bars.

Note

If x has units (e.g., datetime), then the width is converted to a multiple of the width relative to the difference units of the x values (e.g., time difference).

thresholdfloat, optional

Threshold value for color separation (default: 0)

pos_colorstr, optional

Color for bars ≥ threshold (default: ‘red’)

neg_colorstr, optional

Color for bars < threshold (default: ‘blue’)

axmatplotlib axes, optional

Axes object to plot on (uses current axes if None)

**kwargs :

Additional arguments passed to plt.bar

Returns:

matplotlib.container.BarContainer

The bar plot object