Bar#
import hvplot.xarray # noqa
import xarray as xr
Introduction#
A bar
plot represents categorical data with rectangular bars with heights proportional to the numerical values that they represent.
The x-axis represents the categories and the y axis represents the numerical value scale.
The bars are of equal width which allows for instant comparison of data.
Data#
Let’s load some data.
ds = xr.tutorial.open_dataset('air_temperature').load()
air = ds.air
air1d = air.sel(lon=285.,lat=40.).groupby('time.month').mean()
air1d
<xarray.DataArray 'air' (month: 12)> Size: 96B array([272.57443548, 272.86397321, 275.4216129 , 282.50516667, 288.4616129 , 293.99958333, 296.62262097, 295.09346774, 292.44054167, 288.14100806, 279.71479167, 276.71915323]) Coordinates: lat float32 4B 40.0 lon float32 4B 285.0 * month (month) int64 96B 1 2 3 4 5 6 7 8 9 10 11 12 Attributes: long_name: 4xDaily Air temperature at sigma level 995 units: degK precision: 2 GRIB_id: 11 GRIB_name: TMP var_desc: Air temperature dataset: NMC Reanalysis level_desc: Surface statistic: Individual Obs parent_stat: Other actual_range: [185.16 322.1 ]
Basic Bar Plots#
air1d.hvplot.bar(y='air', height=500, title="Air Temperature by Month")
This web page was generated from a Jupyter notebook and not all
interactivity will work on this website.