Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing a second legend

Tags:

r

ggplot2

I have a ggplot, which also displays a legend:

ggplot(dt.m, aes(x=pct.on.OAC.cont,y=Number.of.Practices, fill=Age.Group)) +
    geom_bar(stat="identity",position=position_dodge())

When I add another line, I also get a second legend:

geom_smooth(aes(x=pct.on.OAC.cont,y=Number.of.Practices, colour=Age.Group), se=F, alpha=0.5)

How can I prevent the second legend from displaying ?

like image 488
Robert Long Avatar asked Oct 05 '12 12:10

Robert Long


1 Answers

Use show_guide = FALSE in geom_smooth:

geom_smooth(aes(x=pct.on.OAC.cont,y=Number.of.Practices, colour=Age.Group),
            se=F, alpha=0.5, show_legend = FALSE)

This suppresses drawing a legend.

like image 176
Sven Hohenstein Avatar answered Oct 15 '22 19:10

Sven Hohenstein