0
我有一個ggplot,其中我使用的顏色是我的geom_points
作爲我的一列(我的處理)的函數,然後我使用scale_color_manual
來選擇顏色。ggplot2 - 爲多個圖層添加手動圖例
我自動獲得我的傳說權
的問題是我需要繪製一個與實驗設置,其中我與geom_vline
做做一些水平線,但我不知道如何手動添加一個單獨的圖例,不會混淆我已經擁有的圖例,並說明這些圖線是什麼。
我有以下代碼
ggplot(dcons.summary, aes(x = meters, y = ymean, color = treatment, shape = treatment)) +
geom_point(size = 4) +
geom_errorbar(aes(ymin = ymin, ymax = ymax)) +
scale_color_manual(values=c("navy","seagreen3"))+
theme_classic() +
geom_vline(xintercept = c(0.23,3.23, 6.23,9.23), color= "bisque3", size=0.4) +
scale_x_continuous(limits = c(-5, 25)) +
labs(title= "Sediment erosion", subtitle= "-5 -> 25 meters; standard deviation; consistent measurements BESE & Control", x= "distance (meters)", y="erosion (cm)", color="Treatment", shape="Treatment")
所以我只需要在「處理」一個說下一個額外的傳說「BESE PLOTS位置」,這是關係到灰線
我一直在尋找一個解決方案,我已經使用"scale_linetype_manual"
也"guides"
嘗試過,但我沒有收到有
哦,這很簡單。我已經在嘗試scale_linetype_manual,但並未像你那樣巧妙地將aes添加到geom_vline。 – Locean