我正在制作一个热图通过cooccur包,但我得到了重叠的物种名称。如何解决这个问题?这一情节是由下列代码制作的:
M <- cooccur(mat = M, type = "spp_site", thresh = T, spp_names = TRUE, prob = "hyper")
plot(M, plotrand = TRUE)

发布于 2022-06-19 15:46:34
不幸的是,作者没有在函数中使用定义的主题。在这篇文章中,How to change default font size in R chart @Gregor给出了一个很好的答案。您可以做的是创建自己的theme,就像在ggplot中一样。这里我以finches数据集为例:
library(cooccur)
data("finches")
cooccur.finches <- cooccur(mat=finches,
type="spp_site",
thresh=TRUE,
spp_names=TRUE)
summary(cooccur.finches)
plot(cooccur.finches,cex.sub = 0.1)
p <- plot(cooccur.finches)
p + theme_bw(base_size = 28) +
theme(axis.text = element_blank(),
axis.ticks = element_blank(),
plot.title = element_text(vjust = -4, face = "bold"),
panel.background = element_rect(fill = "white", colour = "white"),
panel.grid = element_blank(),
legend.position = c(0.9, 0.5))输出:

我建议使用来自ggplot的theme选项。这里有一个很好的帖子,可以肯定地帮助你:Changing font size and direction of axes text in ggplot2
发布于 2022-06-19 18:06:12
在开始修改字体大小之前,您应该检查这是否只是R不正确地猜测设备大小而造成的人为问题。我注意到,当用dev.copy将一个情节保存为PDF时,这种情况经常发生,下面的解决方法总是为我解决这个问题:
https://stackoverflow.com/questions/72671222
复制相似问题