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)
How can I make it so that the virginica species is illustrated with a solid black line and no fill?
CodePudding user response:
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:


