# Hsv ¶

Title
HSV Element
Dependencies
Matplotlib
Backends
Matplotlib
Bokeh
In [1]:
import numpy as np
import holoviews as hv
hv.extension('matplotlib')


HoloViews makes it trivial to work in any color space that can be converted to  RGB  by making a simple subclass of  RGB  as appropriate. For instance, we also provide the HSV (hue, saturation, value) color space, which is useful for plotting cyclic data (as the Hue) along with two additional dimensions (controlling the saturation and value of the color, respectively).

Like other raster based Element types  HSV  accepts gridded data, which may be supplied as a simple array  NxMx3  ndarray representing hue, saturation and value channels along with bounds or explicit array coordinates. See the Gridded Datasets user guide to see the accepted data formats.

In [2]:
x,y = np.mgrid[-50:51, -50:51] * 0.1
h = 0.5 + np.sin(0.2*(x**2+y**2)) / 2.0
s = 0.5*np.cos(y*3)+0.5
v = 0.5*np.cos(x*3)+0.5

hsv = hv.HSV(np.dstack([h, s, v]))
hsv

Out[2]:

You can see how this is created from the original channels:

In [3]:
%opts Image (cmap='gray')
hsv[..., 'H'].relabel('H') + hsv[..., 'S'].relabel('S') + hsv[..., 'V'].relabel('V')

Out[3]:

An  HSV  Element can also easily be converted to an  RGB  Element using the  rgb  property:

In [4]:
print(hsv.rgb)
hsv.rgb[..., 'R'] + hsv.rgb[..., 'G'] + hsv.rgb[..., 'B']

:RGB   [x,y]   (R,G,B)

Out[4]:

For full documentation and the available style and plot options, use  hv.help(hv.HSV).