热图图中的重叠标签

发布于 2025-02-08 15:16:56 字数 222 浏览 3 评论 0原文

我正在通过COOCCUR软件包生产热图,但我得到了重叠的物种名称。如何解决? 该图是由以下代码生成的:

M <- cooccur(mat = M, type = "spp_site", thresh = T, spp_names = TRUE, prob = "hyper")
plot(M, plotrand = TRUE)

I am producing a heatmap via cooccur package but I am getting overlapping species names. How to solve it?
The plot was produced by the following codes:

M <- cooccur(mat = M, type = "spp_site", thresh = T, spp_names = TRUE, prob = "hyper")
plot(M, plotrand = TRUE)

enter image description here

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

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

发布评论

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

评论(2

薄荷梦 2025-02-15 15:16:56

不幸的是,作者没有在功能中使用定义的主题。在这篇文章中如何更改R图表中的默认字体大小 @gregor Thomas给出一个很好的答案。您可以做的是创建自己的主题,例如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))

output:

“在此处输入映像说明”

我建议使用ggplot 。这是一个很好的帖子,可以肯定可以帮助您:更改ggplot2中轴文本的字体大小和方向

Unfortunately, the author didn't use defined themes inside the function. In this post How to change default font size in R chart @Gregor Thomas give a nice answer. What you can do is create your own theme like in ggplot. Here I use the finches dataset as an example:

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))

Output:

enter image description here

I would suggest playing around with the theme options from ggplot. Here is a good post which can help you for sure: Changing font size and direction of axes text in ggplot2

千里故人稀 2025-02-15 15:16:56

在开始使用字体尺寸的情况下,您应该检查这是否仅是由R错误猜测设备尺寸引起的人为问题。我已经注意到,当绘图通过dev.copy.copy保存到PDF时,这会定期发生,以下变方法始终为我解决问题:

  1. 调整屏幕上的绘图窗口大小。
  2. 通过再次调用绘图命令来重新绘制情节。

Before you start fiddling with font sizes, you should check whether this is just an artificial problem caused by R incorrectly guessing the device size. I have noticed that this regularly occurs when a plot is saved to PDF with dev.copy and the following workaround always solved the problem for me:

  1. Resize the plotting window on screen.
  2. Redraw the plot by calling the plot command again.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文