Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
holoview_escape.py
import numpy as np
import pandas as pd
from bokeh.models import HoverTool
import holoviews as hv
hv.notebook_extension("bokeh")
df = pd.DataFrame(
dict(
x=np.random.randint(0, 10, 10),
y=np.random.randint(0, 10, 10),
)
)
def svg_data_uri():
return f"""<img src='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"/>'/>"""
df["img"] = svg_data_uri()
def hover_cb(*arg):
return HoverTool(
tooltips=f"""@img"""
)
hover = hover_cb()
opts = dict(Scatter=dict(plot=dict(tools=[hover])))
scatter_plot = hv.Scatter(
df, kdims=["x", "y"], vdims=["img"]
).opts(size=10)
figure = scatter_plot(opts)
figure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.