Is it possible to add a hyperlink to data points in a scatter plot in Plotly in R?
Hi @haleh
It’s not optimal but I usually hide text with a link behind the scatter points (note, this only works when points are spread out).
p <- plot_ly(
type = 'scatter',
mode = 'markers',
x = c(1,2,3,4),
y = c(5,5,5,5),
text = c("<a href='https://google.com'>A</a>",
"<a href='https://google.com'>A</a>",
"<a href='https://google.com'>A</a>",
"<a href='https://google.com'>A</a>")
) %>%
add_trace(
mode = 'text',
textfont = list(
color = 'transparent'
),
showlegend = F
)
Thank you. Its hard to keep mouse in the hyperlink to be able to click on that. Is there any way to improve that?