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
by making a simple subclass of
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
accepts gridded data, which may be supplied as a simple array
ndarray representing hue, saturation and value channels along with bounds or explicit array coordinates. See the
user guide to see the accepted data formats.
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
You can see how this is created from the original channels:
%opts Image (cmap='gray') hsv[..., 'H'].relabel('H') + hsv[..., 'S'].relabel('S') + hsv[..., 'V'].relabel('V')
Element can also easily be converted to an
Element using the
print(hsv.rgb) hsv.rgb[..., 'R'] + hsv.rgb[..., 'G'] + hsv.rgb[..., 'B']
:RGB [x,y] (R,G,B)
For full documentation and the available style and plot options, use