我有一個資料集(下面是一小段摘錄),它繪制了三條線 - 兩條線是從一個具有置信區間的模型估計的,第三條線用作結果的外部確認。
bestFit <- data.frame(Year = c(2006, 2007, 2008,
2006, 2007, 2008,
2006, 2007, 2008),
Estimate = c(4208, 4570, 4925,
0872, 1324, 1193,
6009, 5705, 6474),
Lo95CI = c(2903, 3561, 4036,
0693, 1113, 0999,
NA, NA, NA),
Hi95CI = c(5209, 5453, 5725,
0998, 1489, 1330,
NA, NA, NA),
Reconstruction = c("Abun", "Abun", "Abun",
"Recr", "Recr", "Recr",
"Extl", "Extl", "Extl"))
bestFit$Reconstruction <- factor(bestFit$Reconstruction, ordered = TRUE,
levels = c("Abun", "Recr", "Extl"))
ggplot(aes(y = Estimate, x = Year, fill = Reconstruction), data = bestFit)
geom_ribbon(aes(ymin = Lo95CI, ymax = Hi95CI,
fill = Reconstruction), alpha = 0.25)
geom_point(aes(colour = Reconstruction))
geom_path(aes(colour = Reconstruction), size = 1)
scale_x_continuous(breaks = seq(2006, 2008, 2))
scale_fill_manual(values = c("#F8766D", "#00BA38", "#619CFF"))
scale_color_manual(values = c("#F8766D", "#00BA38", "#619CFF"))
scale_linetype_manual(values = c("solid", "solid", "dotted"))
我可以手動設定顏色,但在手動設定線型時遇到了麻煩。我希望前兩行(來自我的模型)是實線,第三行(來自外部模型)是虛線。
uj5u.com熱心網友回復:
來自評論:
您尚未映射線型美學。linetype = Reconstruction
在您的通話aes
部分中添加。geom_path
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/498311.html