我正在制作带有误差线的多线图。如果我不使用size
参数,一切都很好:
# sample data
Response=runif(4)
ResponseMin=Response-Response/5
ResponseMax=Response+Response/5
Cases=rep(c("Case1","Case2"),each=2)
df=data.frame(x=1:2,Average=Response,Lower=ResponseMin,Upper=ResponseMax,Case=Cases)
# let's plot
library(ggplot2)
ggplot(df,aes(x=x,y=Average,colour=Case)) +
geom_line(aes(group=Case)) +
geom_point() +
geom_errorbar(aes(ymin=Lower,ymax=Upper,width=0.25)) +
labs(y="foo",title="Some plot fu")
但是,当我修改线条大小时,我开始得到奇怪的东西:
ggplot(df,aes(x=x,y=Average,colour=Case)) +
geom_line(aes(group=Case, size = 1)) +
geom_point() +
geom_errorbar(aes(ymin=Lower,ymax=Upper,width=0.25)) +
labs(y="foo",title="Some plot fu")
为什么额外的图例条目“1”?当我为错误栏添加一个size
参数时,看起来线条的大小保持不变,无论值size
是:
ggplot(df,aes(x=x,y=Average,colour=Case)) +
geom_line(aes(group=Case, size = 1)) +
geom_point() +
geom_errorbar(aes(ymin=Lower,ymax=Upper,width=0.25, size = 1)) +
labs(y="foo",title="Some plot fu")
ggplot(df,aes(x=x,y=Average,colour=Case)) +
geom_line(aes(group=Case, size = 2)) +
geom_point() +
geom_errorbar(aes(ymin=Lower,ymax=Upper,width=0.25, size = 2)) +
labs(y="foo",title="Some plot fu")
你能帮我弄清楚这里发生了什么吗?