我有兴趣学习如何为我的散点图着色,以便根据 y 轴上的间隔对点进行着色。我想编写以下代码:<10 = 蓝色,10-20 = 橙色,20-30 = 绿色,& >30 = 紫色。目前,我将颜色设置为 factor(n_ct) 并且我得到了彩虹。此外,我不断收到一条警告消息,上面写着“未定义宽度。使用 'position_dodge(width =?) 设置”即使我在那里有 position = "dodge",所以我不知道这是我的错误还是 rstudios . 我还想添加一条回归线。
performance <- read_csv(performance.csv)
cumulative <- read_csv(cumulative.csv)
performance_2_n_ct <performance %>% select(Sample, AvgCov)
cumulative_2_n_ct <- cumulative %>% select(Sample, n_ct)
cumulative_3_n_ct <- cumulative_2_n_ct %>%
filter(!is.na(n_ct))
all_data_n_ct_ <- left_join(cumulative_3_n_ct, performance_2_n_ct, by = "Sample")
n_ct_finale <- ggplot(data = all_data_n_ct_, aes(y=n_ct, x = AvgCov, color = factor(n_ct))) +
geom_point(stat = "identity", position = "dodge")
我所拥有的图像如下。