Search code examples
data-visualizationbokehholoviews

how to use images as glyphs in holoviews


I am using holoviews with the bokeh backend, but for one of the layers, I need to display images at a number of pionts. I've found this bokeh demo (https://docs.bokeh.org/en/latest/docs/reference/models/glyphs/image_url.html), which does what I want, but I can't figure out how to get add_glyph to work through holoviews.

I'm trying to use holoviews hooks to access the bokeh backend like this:

def update_plot(plot, element):
    plot.state.add_glyph(source, image1)

my_plot.opts(hooks=[update_bouys]

but I'm not getting my images.

I did get images when I used hv.render like below, but that uses the bokeh show, which means I can't overlay it on the rest of my holoviews plots.

b = hv.render(my_plot)
b.add_glyph(source, image1)
show(b)

If anyone can show me a similar example to the bokeh demo that uses holoviews as a front end, that would be awesome. Thank you


Solution

  • In HoloViews you'd just use the RGB element: https://holoviews.org/reference/elements/bokeh/RGB.html

    import holoviews as hv
    hv.extension('bokeh')
    
    hv.Overlay([hv.RGB.load_image('logo.png', bounds=(2*i,2*i,3*i,3*i))
                for i in range(1,8)])
    

    enter image description here