-1

Is there anyway of making geom_legend work with geom_bar? I want to have too lines in my legend. It works for geom_line but not for geom_bar charts.

It works fine when I used it here:

ggplot(diamonds, aes(x,y)) + 
      geom_point(aes(colour = z))+
      guides(col = guide_legend(ncol = 2))

The code it doesn't work for is as follows:

ggplot(diamonds, aes(clarity, fill=cut)) + 
       geom_bar()+
       guides(col = guide_legend(ncol = 2))

Thanks for your help.

1 Answers1

0

Change col to fill in the last line. Color is not the mapped aesthetic, fill is.

tmpname12345
  • 2,891
  • 18
  • 20