ggnet 网络避免标签重叠

问题描述

我正在 R 中使用 ggnet 绘制网络

ggnet2(net2,label = F,palette = col,alpha = 0.75,size = 4,edge.alpha = 0.5,label.size = 2,node.color = "category")

这工作正常,但标签彼此重叠。由于我不想要所有标签,只是在名为 category 的列中指定了一些标签,因此我尝试使用 geom_text_repel()。但是我收到了一个错误


head(ggnetwork(net2))
           x         y  category                          vertex.names       xend      yend
72 0.1527696 0.5879314 microRNAs Dpu-Mir-96-P3_LQNS02278075.1_32307_3p 0.07407189 0.6413515
73 0.1527696 0.5879314 microRNAs Dpu-Mir-96-P3_LQNS02278075.1_32307_3p 0.07355453 0.6360147
74 0.1527696 0.5879314 microRNAs Dpu-Mir-96-P3_LQNS02278075.1_32307_3p 0.02863141 0.6139941
75 0.1527696 0.5879314 microRNAs Dpu-Mir-96-P3_LQNS02278075.1_32307_3p 0.02474171 0.6064790
76 0.1527696 0.5879314 microRNAs Dpu-Mir-96-P3_LQNS02278075.1_32307_3p 0.11799126 0.6751930
77 0.1527696 0.5879314 microRNAs Dpu-Mir-96-P3_LQNS02278075.1_32307_3p 0.06962854 0.6256732

#Label the nodes when category==microRNAs using the names from column vertex.names
ggnet2(net2,node.color = "category") + geom_text_repel(data= ggnetwork(net2)[ggnetwork(net2)$category == "microRNAs",],aes(label=ggnetwork(net2)$vertex.names))

Error: Aesthetics must be either length 1 or the same as the data (1465): label
Run `rlang::last_error()` to see where the error occurred.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...