5

I'm using GeoViews to plot maps of gridded data, as gv.Image object. Currently, my plotting function looks like this:

def plot_variable(path):
    var_ = xr.open_dataarray(path)
    dataset = gv.Dataset(var_[:, 0].to_dataset(),
                     kdims=kdims, vdims=vdims)

    pl_ = hv.Overlay([
              dataset.to(gv.Image, geo_dims, crs=prj_)(
                      plot=dict(projection=prj_, vmax=0.04)),
              gf.coastline(plot=dict(projection=prj_, scale='10m'),
                           style=dict(linewidth=2.5)),
              gf.borders(plot=dict(projection=prj_, scale='10m'),
                   style=dict(linewidth=1.5)),
              ]).collate()

    return pl_

Now, I would like to set the minima and maxima of the color's range, i.e., the HoloViews equivalent of the vmin and vmax kwargs.

How can I set vmin and vmax when using gv.Image?

andreas-h
  • 10,679
  • 18
  • 60
  • 78

2 Answers2

3

@eudoxos: You could use the clim parameter in the .opts options like

 import holviews as hv
 vmin=0
 vmax=0.4
 hv.Image(np.random.randn(4, 5)).opts(cmap='gray',clim=(vmin,vmax))

Output of above command

Joe Sar
  • 41
  • 6
2

You can change the range of the value dimension of the image:

import holoviews as hv
img = hv.Image(np.random.randn(4, 5))
img.redim(z=dict(range=(-10, 10)))
HYRY
  • 94,853
  • 25
  • 187
  • 187