【问题标题】:Create a RDA biplot using extracted RDA results and merge to graphs使用提取的 RDA 结果创建 RDA 双图并合并到图形
【发布时间】:2018-03-26 02:53:28
【问题描述】:

目前正在尝试使用提取的数据来创建两个单独的 RDA 双图。使用以下代码:

p <- ggplot()
p + geom_vline(x=0,colour="grey50") +
    geom_hline(y=0,colour="grey50") +
    geom_text(data = PHYTOPLANKTON_coordinates_scaling_2, aes(x = RDA1, y = RDA2, 
          label=rownames(PHYTOPLANKTON_coordinates_scaling_2)), angle=45, size=3,
          colour = 'blue') +
    geom_segment(data = WQ_coordinates_scaling_2, aes(x = 0, y = 0, 
          xend = RDA1, yend = RDA2), size = 0.5, colour = 'red') +
    geom_text(WQ_coordinates_scaling_2, aes(x = RDA1, y = RDA2,
          label = rownames(WQ_coordinates_scaling_2)), size = 5, angle = 45, 
          vjust = 1, colour = 'violet') +
    theme_bw()

这会导致:

错误:意外的 '=' in: " + geom_text(data = PHYTOPLANKTON_coordinates_scaling_2, aes(x = RDA1, y = RDA2, + 标签=" + color = 'blue') 错误:" + color = '蓝色')"

【问题讨论】:

  • 请根据 SO 指南编辑您的帖子。

标签: r ggplot2 rda


【解决方案1】:
set.seed(123)
# Generate toy data
n <- 20
PHYTOPLANKTON_coordinates_scaling_2 <-
data.frame(RDA1 = rnorm(n), RDA2 = rnorm(n))
rownames(PHYTOPLANKTON_coordinates_scaling_2) <- LETTERS[1:n]    
k <- 4
WQ_coordinates_scaling_2 <-
data.frame(RDA1 = rnorm(k), RDA2 = rnorm(k))
rownames(WQ_coordinates_scaling_2) <- paste0("V",1:k)

# Plot data   
library(ggplot2)
p <- ggplot()
p + geom_vline(xintercept=0,colour="grey50") +
    geom_hline(yintercept=0,colour="grey50") +
    geom_text(data=PHYTOPLANKTON_coordinates_scaling_2, aes(x=RDA1, y=RDA2, 
          label=rownames(PHYTOPLANKTON_coordinates_scaling_2)), angle=45, size=3,
          colour = 'blue') +
    geom_segment(data=WQ_coordinates_scaling_2, aes(x = 0, y = 0, 
          xend = RDA1, yend = RDA2), size = 0.5, colour = 'red') +
    geom_text(data=WQ_coordinates_scaling_2, aes(x=RDA1, y=RDA2,
          label = rownames(WQ_coordinates_scaling_2)), size = 5, angle = 45, 
          vjust = 1, colour = 'violet') +
    theme_bw()

【讨论】:

    猜你喜欢
    • 2015-11-10
    • 2014-05-13
    • 2019-11-20
    • 2020-08-31
    • 2018-01-05
    • 2019-09-02
    • 1970-01-01
    • 1970-01-01
    • 2020-05-19
    相关资源
    最近更新 更多