I am visualizing a UMAP 2D reduction of a Doc2Vec vector space as an interactive scatter plot with Plotly.
Each point corresponds to a document vector. Aside from the hovering behavior (which displays some information about the document), I want to be able to click on the points so that the URL of the document opens in a new window.
Here is my current code for the figure:
fig = go.Figure()
for cat in data.Categories.unique():
if cat != 'OTHER':
cat_data = data[data['Categories'] == cat]
fig.add_trace(go.Scattergl(
x=cat_data["Component 1"],
y=cat_data["Component 2"],
name=cat,
mode="markers",
opacity=0.8,
marker=dict(size=5),
text=['Label: %s<br>Title: %s'%(d,t) for d,t in cat_data.loc[:,['Labels', 'Document Titles']].values],
hoverinfo="text"
))
fig.update_layout(
title=title,
font=dict(
family="Lato",
size=16,
color="#000000"),
hovermode='closest'
)
fig.write_html("Plotly/2D_[NN-%s]_[MD-%s].html"%(n_neighbors, min_dist))
I have no idea where to start, reading through Plotly documentation didn't seem to help.
Many thanks in advance!