![](/img/trans.png)
[英]Overlay 10 density plots in R with colour proportional to number of overlapping plots
[英]R - Overlay multiple least squares plots with colour coding
我正在嘗試可視化一些看起來像這樣的數據
line1 <- data.frame(x = c(4, 24), y = c(0, -0.42864), group = "group1")
line2 <- data.frame(x = c(4, 12 ,24), y = c(0, 2.04538, 3.4135), group = "group2")
line3 <- data.frame(x = c(4, 12, 24), y = c(0, 3.14633, 3.93718), group = "group3")
line4 <- data.frame(x = c(0, 3, 7, 12, 18), y = c(0, -0.50249, 0.11994, -0.68694, -0.98949), group = "group4")
line5 <- data.frame(x = c(0, 3, 7, 12, 18, 24), y = c(0, -0.55753, -0.66006, 0.43796, 1.38723, 3.17906), group = "group5")
df <- do.call(rbind, list(line1, line2, line3, line4, line5))
我要做的是 plot 同一 plot 上每個組的最小二乘線(和點)。 我希望線條和點的顏色與組相對應。
我所能做的就是 plot 根據他們的小組得分
ggplot(data = df, aes(x, y, colour = group)) + geom_point(aes(size = 10))
但我不知道如何添加線條並使它們的顏色與它們適合的點相對應。
我真的很感激這方面的任何幫助。 事實證明它比我想象的要困難得多。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.