我在R中绘制了大量的Spearman相关性分析。我希望在绘图中包含R值标签,但我不想包含p值。我的实际图的样本量都很大,所以所有的p值都很小,并且它们的包含不会给图添加任何有用的东西。在创建单独的图之后,我使用gridExtra::grid.arrange来合并图,而额外的标签长度正在阻碍我(更清晰地包含图本身之外的信息)。
我已经看到了改变标签大小和位置的方法,但还没有找到任何限制或调整标签内容输出的方法。有没有可能在stat_cor中删除绘图中的p值,但保留R?有没有其他的包可以进行更多的定制?

下面是我用来生成绘图的基本代码。
df %>%
ggscatter(x = "Diameter", y = "Depth",
add = "reg.line", conf.int = TRUE,
title = "test",
xlab = "Diameter (m)", ylab = "Depth (m)",
shape = 21, fill = "lightgray", color = "black", size = 3) +
stat_cor(method = "spearman", label.x = 0.45, label.y = 1.2) +
coord_cartesian(ylim = c(0,1.25), xlim = c(0,0.7)) +
theme_minimal()这里基本上是使用iris数据集的相同设置。

ggscatter(data = iris,x = "Sepal.Length", y = "Sepal.Width",
add = "reg.line", conf.int = TRUE,
title = "Iris test",
xlab = "Length", ylab = "Width",
shape = 21, fill = "lightgray", color = "black", size = 3) +
stat_cor(method = "spearman") +
theme_minimal()发布于 2020-05-04 12:34:09
从这个github问题中发现了一些提示:https://github.com/kassambara/ggpubr/issues/32,然后使用ggplot对象来查看正在构建的所有不同的属性。
ggscatter(data = iris,x = "Sepal.Length", y = "Sepal.Width",
add = "reg.line", conf.int = TRUE,
title = "Iris test",
xlab = "Length", ylab = "Width",
shape = 21, fill = "lightgray", color = "black", size = 3)+
stat_cor(r.digits = 2, method = "spearman",
aes(label = paste("'R = '", ..r.., sep = " "))
)

https://stackoverflow.com/questions/61584413
复制相似问题