从ggplot中的图例中删除一个(或多个)aes

时间:2013-12-17 14:18:54

标签: r ggplot2

这肯定是一个简单的问题,但我找不到快速简便的解决方案。 我只是想从图例中删除一个aes,例如在图中,我不希望出现“2点”:

enter image description here

顺便说一下,这就是情节的代码:

ggplot(subset(df, df$ID %in% c( "B4F", "B3F", "B33F", "B2F", "B0F")), 
       aes(Date, SO4, color=ID))+
  geom_smooth(method="loess", se=F, size=1)+
  geom_point(data=subset(df_1, df_1$ID %in% c( "B4F", "B3F", "B33F", "B2F", "B0F")),
             aes(Date, SO4, color=ID, size=2, legend=FALSE))+
  scale_x_date(labels= date_format("%Y"), breaks=date_breaks("year"))+
  xlab(NULL)

1 个答案:

答案 0 :(得分:1)

size=2中删除aes。因此,改变

geom_point(data=subset(df_1, df_1$ID %in% c( "B4F", "B3F", "B33F", "B2F", "B0F")),
             aes(Date, SO4, color=ID, size=2, legend=FALSE))

geom_point(data=subset(df_1, df_1$ID %in% c( "B4F", "B3F", "B33F", "B2F", "B0F")),
                 aes(Date, SO4, color=ID, legend=FALSE), size=2)

在后一段代码中,size=2仍在geom_point内,但在aes之外。