10

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 ?

Robert Long
  • 5,722
  • 5
  • 29
  • 50

1 Answers1

15

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.

wake_wake
  • 1,332
  • 2
  • 19
  • 46
Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168
  • 2
    In the new ggplot2, the command is show.legend = FALSE. But everything else is the same. – bshor Mar 09 '16 at 20:50