-1

Why isn't my legend showing up when I plot this?

ggplot(data=baseline_total, aes(x=sighd_rater_total, color="sighd_rater_total")) + 
geom_area(stat="bin", col = 'light blue', fill='light blue') + 
geom_freqpoly(data=baseline_total,aes(x=sighd_tier1_total, color="sighd_tier1_total"), stat = "bin", col = 'dark blue')
Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102

1 Answers1

1

If you specify the colour (or fill, shape, etc.) within the aes() you need to do so without "" in order to get a legend based on that variable. So this will probably work:

ggplot(data = baseline_total, aes(x = sighd_rater_total, colour = sighd_rater_total)) + 
geom_area(stat="bin", colour = "light blue", fill = "light blue") + 
geom_freqpoly(data = baseline_total, aes(x = sighd_tier1_total, colour = sighd_tier1_total), stat = "bin")
erc
  • 10,113
  • 11
  • 57
  • 88