R 如何突出显示两条线之间的区域?ggplot
我有一个包含变量的数据框,它是conf.intervalR 如何突出显示两条线之间的区域?ggplot,r,ggplot2,R,Ggplot2,我有一个包含变量的数据框,它是conf.interval time x x.upper x.lower 1 1.00 0.91 1.11 2 1.03 0.92 1.13 3 1.03 0.95 1.17 2 1.06 0.90 1.13 Iggplotit: library(ggplot2) ggplot(data = df,aes(time,x))+ geom_line(ae
time x x.upper x.lower
1 1.00 0.91 1.11
2 1.03 0.92 1.13
3 1.03 0.95 1.17
2 1.06 0.90 1.13
Iggplot
it:
library(ggplot2)
ggplot(data = df,aes(time,x))+
geom_line(aes(y = x.upper), colour = 'red') +
geom_line(aes(y = x.lower), colour = 'blue')+
geom_line()
我想突出显示红蓝线之间的区域,类似于
geom_smooth()
函数。我该怎么做呢?一个geom_色带
正是您所需要的
ggplot(data = df,aes(time,x))+
geom_ribbon(aes(x=time, ymax=x.upper, ymin=x.lower), fill="pink", alpha=.5) +
geom_line(aes(y = x.upper), colour = 'red') +
geom_line(aes(y = x.lower), colour = 'blue')+
geom_line()
能否添加图例以识别蓝线和红线的颜色?使用
geom_线(aes(y=x.upper,color='upper'))
和geom_线(aes(y=x.lower,color='lower')
自动创建色标和图例