如何让ggplot识别"repel"参数
How to make ggplot recognize the "repel" parameter
我正在尝试 运行 geom_nodetext 和 geom_edgetext 中的排斥功能,但无法使其正常工作...我总是收到以下错误消息:
警告信息:
忽略未知参数:排斥。
你知道如何让它发挥作用吗?示例如下
library(NetworkToolbox)# version 1.4.1
library(dplyr)#version1.02
library(ggplot2)# version3.3.3
library(ggnetwork) #version0.5.8
library(ggrepel) #0.9.1
M1 <- as_tibble(replicate(21,sample(1:3,100,rep=TRUE)))
colnames(M1) <- c("Wordtoolong1st", "Wordtoolong2nd", "Wordtoolong3th", "Wordtoolong4th", "Wordtoolong5th",
"Wordtoolong6th","Wordtoolong7th","Wordtoolong8th","Wordtoolong9th","Wordtoolong10th",
"Wordtoolong11th","Wordtoolong12th","Wordtoolong13th","Wordtoolong14th","Wordtoolong15th",
"Wordtoolong16th","Wordtoolong17th","Wordtoolong18th","Wordtoolong19th",
"Wordtoolong20th","Wordtoolong21th")
M2 <- as.matrix(round(cor(M1[,],method ="kendall"),2))
MAST <- MaST(M2, normal = False)
gr4ph <- graph.adjacency(MAST , mode = "lower",weight=TRUE)
gg <- ggnetwork(gr4ph, arrow.gap = 0, layout = layout_with_fr(gr4ph))
ggplot(gg, aes(x = x, y = y, xend = xend, yend = yend)) +
geom_edges(color = "grey", alpha = 1, curvature = 0.1) +
geom_nodes(aes(color = name), size = 6) + theme_blank() +
geom_nodetext(aes(label = name), color = "black", size = 3.5,repel=TRUE) +
geom_edgetext(aes(label = weight), size = 3,alpha=0.01,repel= TRUE) +
theme(plot.margin = unit(c(0, 1, 2, 4), "cm"))+
guides(color = guide_legend(keyheight = 0.09, keywidth = 0.09,
title = "Mots")) + theme(legend.position = c(-0.05, 0.14),
legend.background = element_blank(),
legend.text = element_text(size = 7))
谢谢
示例代码中的 geom_nodetext
和 geom_edgetext
调用包含无法识别的 repel = TRUE
参数。两个几何图形都应使用与 geom_text_repel
相同的参数才能工作。参数也显示在例如下。 ?geom_nodetext
.
其余代码看起来不错。
我正在尝试 运行 geom_nodetext 和 geom_edgetext 中的排斥功能,但无法使其正常工作...我总是收到以下错误消息: 警告信息: 忽略未知参数:排斥。 你知道如何让它发挥作用吗?示例如下
library(NetworkToolbox)# version 1.4.1
library(dplyr)#version1.02
library(ggplot2)# version3.3.3
library(ggnetwork) #version0.5.8
library(ggrepel) #0.9.1
M1 <- as_tibble(replicate(21,sample(1:3,100,rep=TRUE)))
colnames(M1) <- c("Wordtoolong1st", "Wordtoolong2nd", "Wordtoolong3th", "Wordtoolong4th", "Wordtoolong5th",
"Wordtoolong6th","Wordtoolong7th","Wordtoolong8th","Wordtoolong9th","Wordtoolong10th",
"Wordtoolong11th","Wordtoolong12th","Wordtoolong13th","Wordtoolong14th","Wordtoolong15th",
"Wordtoolong16th","Wordtoolong17th","Wordtoolong18th","Wordtoolong19th",
"Wordtoolong20th","Wordtoolong21th")
M2 <- as.matrix(round(cor(M1[,],method ="kendall"),2))
MAST <- MaST(M2, normal = False)
gr4ph <- graph.adjacency(MAST , mode = "lower",weight=TRUE)
gg <- ggnetwork(gr4ph, arrow.gap = 0, layout = layout_with_fr(gr4ph))
ggplot(gg, aes(x = x, y = y, xend = xend, yend = yend)) +
geom_edges(color = "grey", alpha = 1, curvature = 0.1) +
geom_nodes(aes(color = name), size = 6) + theme_blank() +
geom_nodetext(aes(label = name), color = "black", size = 3.5,repel=TRUE) +
geom_edgetext(aes(label = weight), size = 3,alpha=0.01,repel= TRUE) +
theme(plot.margin = unit(c(0, 1, 2, 4), "cm"))+
guides(color = guide_legend(keyheight = 0.09, keywidth = 0.09,
title = "Mots")) + theme(legend.position = c(-0.05, 0.14),
legend.background = element_blank(),
legend.text = element_text(size = 7))
谢谢
示例代码中的 geom_nodetext
和 geom_edgetext
调用包含无法识别的 repel = TRUE
参数。两个几何图形都应使用与 geom_text_repel
相同的参数才能工作。参数也显示在例如下。 ?geom_nodetext
.
其余代码看起来不错。