Using ggplot2
it is very easy to create stacked histograms:
library(ggplot2)
ggplot(data = iris, aes(x = Sepal.Length, fill = Species)) +
geom_histogram(colour = 'white')
ggplot(data = iris, aes(x = Sepal.Length, fill = Species)) +
geom_histogram(colour = 'white', position = 'fill')
I would like to know how to create both histograms using only R base graphics .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.