Upon further research, I think I found a potential solution by using annotations
.The idea is to hide the text from the markers
and instead use annotations
for the node labels. This way you can include any arbitrary character vector for the hoverinfo
tooltip texts.
hover_text <- rep('Game Designer/Mario Creator',11)
size = c(100,rep(40,length(vs)-1))
network <- plot_ly(type = "scatter", x = Xn, y = Yn, mode = "markers",
text = hover_text, hoverinfo = "text",marker=list(size=size,color='5BC0DE')
)
edge_shapes <- list()
for(i in 1:Ne) {
v0 <- es[i,]$V1
v1 <- es[i,]$V2
edge_shape = list(
type = "line",
line = list(color = "DF691A", width = 1),
x0 = Xn[match(v0,names(vs))],
y0 = Yn[match(v0,names(vs))],
x1 = Xn[match(v1,names(vs))],
y1 = Yn[match(v1,names(vs))],
opacity = 0.3
)
edge_shapes[[i]] <- edge_shape}
network <- layout(
network,
paper_bgcolor="#4e5d6c",
plot_bgcolor="#4e5d6c",
hovermode = "closest",
title = paste("Miyamoto's Relations",sep = ""),
titlefont=list(color="white"),
shapes = edge_shapes,
xaxis = list(title = "", showgrid = FALSE, showticklabels = FALSE, zeroline = FALSE),
yaxis = list(title = "", showgrid = FALSE, showticklabels = FALSE, zeroline = FALSE),
annotations=list(x = Xn,
y = Yn,
text = names(vs),
xref = "x",
yref = "y",
showarrow = F,
font=list(family = "calibri",
size = 15,
color = "white",
opacity = 1))
)
network