如何在ggplot2中更改组的默认美学

时间:2014-02-15 18:06:03

标签: r ggplot2

我试图在创建错误图时覆盖默认设置。例如,我在以下代码段中有两个不同的“级别”:

plot<-ggplot(df, aes(x=variable, y=value, colour=Levels, group=Levels)) + 
    geom_errorbar(aes(ymin=value-se, ymax=value+se), colour="black", width=.1, position=pd) +
    geom_line(position=pd) +
    geom_point(position=pd, size=3, shape=21, fill="white"))

我想绘制一个黑白显示,geom_line显示两个组成员的连续和虚线,geom_point阴影为黑色为一个,白色为另一个级别。

到目前为止,我无法让lty=c("1","2")fill=c("white", "black")工作。

1 个答案:

答案 0 :(得分:1)

    plot<-ggplot(mdf, aes(x=variable, y=value, fill=Levels,   
    group=Levels,linetype=Levels))+ 
    geom_errorbar(aes(ymin=value-se, ymax=value+se), colour="black", width=.1,   
    position=pd) +
    geom_line(position=pd, colour="black")+scale_shape_manual(values=c("1","2"))+
    geom_point(position=pd, size=3, shape=21, colour="black")+
    scale_fill_manual(values=c("white","black")))