如何使用工具提示创建网络图:igraph,ggraph,networkd3?

发布于 2025-02-06 10:09:20 字数 1289 浏览 2 评论 0 原文

这个问题是 ggraph填充的箭头(已解决),但现在我想在节点中添加动态工具提示,以便能够显示更多的信息,而不是静态图像中可以完成的信息。

所有数据,我到目前为止尝试过的内容&我的R代码在此rpubs文档中: https://rpubs.com/friendly/friffly/eda-network

可以使用“代码</>”下载脚本。按钮:

这是我使用 igraph ggraph ggraph :

我尝试使用 plotly plotly plotly :: ggplotly(),但是 ggraph 使用的大多数Geoms 均未通过 ggplotly 识别,而我所得到的只是要点。

这是我想创建的内容的模型,当我悬停在节点上时,显示一个文本框工具提示。

有人可以建议(a)我如何使用 ggraph 将其作为基础或(b)可以工作的其他网络图软件包来做到这一点。

This question is a followup to ggraph make filled arrow edges appear in legend (solved), but now I would like to add dynamic tooltips to the nodes to be able to show more information than can be done in a static image.

All the data, what I've tried so far & my R code is in this Rpubs document: https://rpubs.com/friendly/EDA-network

The script can be downloaded with the "code </>" button: https://rstudio-pubs-static.s3.amazonaws.com/912944_f40ed4eb53a242268ef57b7329d21d64.html#

Here is the network diagram I created using igraph and ggraph:

enter image description here

I tried using plotly::ggplotly() but most of the geoms used by ggraph are not recognized by ggplotly and all I got were points.

Here is a mockup of what I'd like to create showing a textbox tooltip when I hover over a node.

enter image description here

Can someone suggest either (a) how I can do this using the ggraph plot as a base or (b) a different network diagram package that could work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肥爪爪 2025-02-13 10:09:22

不确定这会有所帮助,但是对我来说,它可以通过:

ggg <- #output from ggraph
thism <- ggg + 
    ggiraph::geom_point_interactive(
         mapping = aes(x, y, tooltip = "string"), colour = "green",alpha=0,size=4)
htmlwidgets::saveWidget(
    girafe(ggobj = thism, width_svg = 20, height_svg = 20,
          options = list(opts_sizing(rescale = FALSE))),
"test2.html")

Not sure this helps, but for me it worked via:

ggg <- #output from ggraph
thism <- ggg + 
    ggiraph::geom_point_interactive(
         mapping = aes(x, y, tooltip = "string"), colour = "green",alpha=0,size=4)
htmlwidgets::saveWidget(
    girafe(ggobj = thism, width_svg = 20, height_svg = 20,
          options = list(opts_sizing(rescale = FALSE))),
"test2.html")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文