小编Gab*_*lai的帖子

与'text'参数不同的plotly R图表上的自定义hoverinfo文本?

我一直在尝试使用plotlyR 库创建网络图。我想可视化与为标记(或在这种情况下为节点)定义的文本标签不同的自定义hoverinfo文本。

基本上,我希望将标记(节点)上的文本标签保持为当前状态,但也能够为hoverinfo. 正如我希望工具提示显示与标记的标签文本不同的一些其他字符向量。例如,当我将鼠标悬停在中央“Shigeru Miyamoto”节点上时,我希望工具提示显示我可能收集的其他信息(例如类型、国籍等)。我从 plotly 文档中的理解是,目前您只能为标记和悬停信息工具提示显示相同的文本标签。

有没有办法做到这一点?

这是我使用的代码:

library(plotly)
library(igraph)
library(dplyr)

A <- data.frame(A=rep("Shigeru Miyamoto",10))

B <- data.frame(B=c("Ninendo Company Ltd","Super Mario Bros","Mario", "Gamespot","Time Magazine","Wii","DOnkey Kong Jr","Mario Kart","Japan","Mario Party"))

edgelist <- bind_cols(A,B)

graph <- graph_from_data_frame(edgelist)
L <- layout_nicely(graph)
vs <- V(graph)
es <- as.data.frame(get.edgelist(graph))
Ne <- length(es[1]$V1)
Xn <- L[,1]
Yn <- L[,2]

txt <- list(
        family = "calibri",
        size = 15,
        color = "white",
        opacity = 1
)

size = c(20,rep(5,length(vs)-1)) …
Run Code Online (Sandbox Code Playgroud)

r plotly

5
推荐指数
1
解决办法
4017
查看次数

标签 统计

plotly ×1

r ×1