To include the number of counts, you can just set labels=TRUE
.
The example below is just slightly adapted from one on the hist()
help page:
hist(islands, col="gray", labels = TRUE, ylim=c(0, 45))
Getting percentages is a bit more involved. The only way I know to do that it to directly manipulate the object returned by a call to hist()
, as described in a bit more detail in my answer to this similar question:
histPercent <- function(x, ...) {
H <- hist(x, plot = FALSE)
H$density <- with(H, 100 * density* diff(breaks)[1])
labs <- paste(round(H$density), "%", sep="")
plot(H, freq = FALSE, labels = labs, ylim=c(0, 1.08*max(H$density)),...)
}
histPercent(islands, col="gray")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…