This is my R script to draw the density plot:

df <- iris
plot(density(df$Sepal.Length), main="Density Plot", ylab="Frequency", sub=paste("Skewness:", round(e1071::skewness(df$Sepal.Length), 2)))

Is there a way to plot three density plots (one for every species: setosa, virginica and versicolor) in the same graph?

  • $\begingroup$ try seaborns density plot $\endgroup$ Aug 11, 2022 at 22:00

1 Answer 1


For plotting I prefer to use the ggplot2 package since I find it easier to use and more versatile. Using this package you can easily plot multiple density plots:


iris %>%
  ggplot(aes(x=Sepal.Length, colour=Species)) +

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.