Rgb#

Download this notebook from GitHub (right-click to download).


import hvplot.xarray  # noqa

rgb can be used to display images that are distributed as three separate “channels” or “bands”.

from hvplot.sample_data import landuse

da = landuse(landuse='airplane', id=90).read()
da
<xarray.DataArray (y: 256, x: 256, channel: 3)>
array([[[123, 113, 106],
        [120, 110, 103],
        [119, 107, 103],
        ...,
        [172, 160, 148],
        [174, 162, 150],
        [174, 163, 152]],

       [[124, 114, 107],
        [124, 112, 106],
        [120, 107, 104],
        ...,
        [171, 159, 147],
        [172, 161, 149],
        [173, 162, 151]],

       [[118, 109, 104],
        [114, 104,  98],
        [114, 103,  98],
        ...,
...
        ...,
        [ 91,  77,  62],
        [ 92,  75,  64],
        [ 91,  75,  66]],

       [[164, 156, 148],
        [172, 165, 155],
        [174, 167, 156],
        ...,
        [ 89,  74,  61],
        [ 90,  72,  61],
        [ 89,  71,  61]],

       [[164, 157, 148],
        [158, 151, 141],
        [156, 150, 139],
        ...,
        [ 88,  74,  60],
        [ 88,  69,  58],
        [ 89,  70,  58]]], dtype=uint8)
Coordinates:
  * y        (y) int64 0 1 2 3 4 5 6 7 8 ... 247 248 249 250 251 252 253 254 255
  * x        (x) int64 0 1 2 3 4 5 6 7 8 ... 247 248 249 250 251 252 253 254 255
  * channel  (channel) int64 0 1 2

Since rgb images are stored starting at the top left pixel, we should start there when plotting to make sure that we get the picture in the correct orientation. To accomplish this, we use flip_yaxis.

da.hvplot.rgb(x='x', y='y', bands='channel', data_aspect=1, flip_yaxis=True, xaxis=False, yaxis=None)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).