我有興趣學習如何為我的散點圖著色,以便根據 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")
我所擁有的影像如下。

如果您有要使用的特定顏色,可以使用scale_color_manual():
...
scale_color_manual(values = c("red",
"cornflowerblue",
"green",
"purple"))

轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/409163.html
標籤:
