Is there a way to use ImageURL from Bokeh in HoloViews / hvplot?

import pandas as pd
import holoviews as hv
from bokeh.models import ImageURL
hv.extension("bokeh")

url = "https://static.bokeh.org/logos/logo.png"
df = pd.DataFrame({"x": [0], "y": [0], "w": [1], "h": [1], "url": [url]})
hv.Points(df, ["x", "y"], ["url"])

I want to do something like:

Something like

See RGB — HoloViews v1.16.2

Haha I suppose that’s a workaround. Thanks!

I’d still be interested whether it can be passed more naturally like the code above so hvplot can do it too.

df.hvplot("x", "y", image="url")

Maybe something with image_url method.

1 Like

Maybe you should ask in your ChatBox :smile:

1 Like

Use case is so I can do something like this (using those hurricane symbols instead of just dots)

1 Like

Okay, I just searched HoloViews repo for image_url and it doesn’t exist. I suspect maybe there can be a new hv.ImageUrl() implementation to match this:

from bokeh.core.properties import value
from bokeh.plotting import figure, show
import numpy as np

url = "https://static.bokeh.org/logos/logo.png"
x = np.random.random(150) * 100
y = np.random.random(150) * 100

p = figure(match_aspect=True, toolbar_location=None, background_fill_color="#efefef")

# value is used here to prevent the string URL from being
# interpreted as a column name from the data source.
p.image_url(
    url=value(url),
    x=x,
    y=y,
    alpha=0.7,
    anchor="center",
    w=18,
    w_units="screen",
    h=18,
    h_units="screen",
)

show(p)

Once GitHub is up again, I’ll file an issue.

def watermark(plot, element):
    plot.handles['plot'].grid.band_hatch_extra={'mycustom': ImageURLTexture(url='https://i.ibb.co/qJ8Y6Ph/03.png')}
    plot.handles['plot'].grid.band_hatch_pattern = 'mycustom'

This is using ImageURLTexture and hatch patterns to create a watermark, but you can probably also use ImageURL alone with hooks.

2 Likes