Hi,
On Wed, Oct 24, 2012 at 2:13 PM, Wasteva <
steve...@gmail.com> wrote:
> Can someone help me to include corresponding percentages of histograms sit
> on the individual blocks. Please I don't mean percentages on the y-axis.
There are really two issues here: 1) getting percentages on the
y-axis, and 2) getting the labels on top of the bars.
For the first one:
ggplot(mtcars, aes(x=mpg, y=..count../sum(..count..))) +
geom_histogram() +
scale_y_continuous("Percent", labels=percent)
For the second one:
ggplot(mtcars, aes(x=mpg, y=..count.., label=..count..)) +
geom_histogram() +
geom_text(stat="bin")
putting it all together we get
ggplot(mtcars, aes(x=mpg, y=..count../sum(..count..),
label=scales::percent(..count../sum(..count..)))) +
geom_histogram() +
geom_text(stat="bin") +
scale_y_continuous("Percent", labels=percent)
Hope that helps!
Ista