我有一个 ggplot,我在其中使用颜色作为我geom_points
的一个列(我的处理)的函数,然后我使用scale_color_manual
来选择颜色。
我自动得到我的传奇
问题是我需要绘制一些与我正在使用的实验设置有关的水平线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 LOCATION”并且与灰线有关
我一直在寻找解决方案,我尝试过使用"scale_linetype_manual"
and "guides"
,但我没有到达那里