Image#

import hvplot.xarray  # noqa
import xarray as xr

ds = xr.tutorial.open_dataset('air_temperature')
ds
<xarray.Dataset> Size: 31MB
Dimensions:  (lat: 25, time: 2920, lon: 53)
Coordinates:
  * lat      (lat) float32 100B 75.0 72.5 70.0 67.5 65.0 ... 22.5 20.0 17.5 15.0
  * lon      (lon) float32 212B 200.0 202.5 205.0 207.5 ... 325.0 327.5 330.0
  * time     (time) datetime64[ns] 23kB 2013-01-01 ... 2014-12-31T18:00:00
Data variables:
    air      (time, lat, lon) float64 31MB ...
Attributes:
    Conventions:  COARDS
    title:        4x daily NMC reanalysis (1948)
    description:  Data is from NMC initialized reanalysis\n(4x/day).  These a...
    platform:     Model
    references:   http://www.esrl.noaa.gov/psd/data/gridded/data.ncep.reanaly...

When data values are available on an x, y grid, they can often be represented as an image.

ds.hvplot.image()

This is equivalent to specifying:

ds.hvplot.image(x='lon', y='lat', z='air', groupby='time', cmap='kbc_r')

A simpler case would be to take the temperature at just one day. Here we’ll show how to use clabel to control the colorbar and also demonstrate how when the data are symmetric around 0, the “coolwarm” colormap is used by default.

time = '2014-01-01'
data = ds.sel(time=time).mean('time') - 273  # convert to celsius

data.hvplot.image(x='lon', y='lat', z='air', title=time, clabel='T [C]')

We can also override the colorbar ticks and labels with cticks, specified as an integer, list of ticks positions, or list of tuples of the tick positions and labels.

data.hvplot.image(x='lon', y='lat', z='air', title=time, clabel='T [C]', cticks=[(-40, "Below Freezing"), (0, "Freezing"), (40, "Above Freezing")])

Geographic Data#

By setting coastline=True, we can add a coastline feature to the plot and coerce it to the proper aspect.

data.hvplot.image(coastline=True)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.