0

I would like to compare distributions using geom_density, but I want one of the distributions to have no fill. I can describe more easily using the following example:

library(dplyr)
library(ggplot2)
iris %>% ggplot() + 
   geom_density(aes(x = Sepal.Width, color = Species, fill = Species), alpha = 0.5) 

enter image description here

How can I make it so that the virginica species is illustrated with a solid black line and no fill?

nicholas
  • 903
  • 2
  • 12

1 Answers1

3
iris %>% 
  ggplot(aes(Sepal.Width)) + 
  geom_density(aes(fill = Species), alpha = 0.5) + 
  scale_fill_manual(values = c("setosa" = "red", 
                               "versicolor" = "green", 
                               "virginica" = "NA"))

Result:

enter image description here

neilfws
  • 32,751
  • 5
  • 50
  • 63