I'm trying to use ggplot to make a histogram where the area of each bin is the total number of occurrences in each bin. So in essence I'm looking to scale the histogram height down by a factor of the bin height. I can create a normal histogram without issue, but I'm not quite sure how to scale the histogram in such a manner. The data and unscaled-histogram are given below. Any help would be much appreciated.
times <- c(71, 72, 73, 74, 75, 76, 77, 78, 79, 80)
occurrences <- c(2, 0, 3, 5, 4, 1, 3, 1, 0, 1)
df <- data.frame("times" = rep(times, occurrences))
ggplot(df, aes(times)) + geom_histogram(breaks=seq(70.5,80.5,2),
colour = "black", size = 2) + ylab("Frequencies") + ylim(0,10) +
ggtitle("Bin Width = 2 (un-scaled)")
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.