Created
October 22, 2019 15:32
-
-
Save goraj/ac67d5aed340a07d3d7c30bc5179c7de to your computer and use it in GitHub Desktop.
holoview_escape.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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