kittenlee kittenlee - 1 year ago 89
R Question

ggplot transform y axis histogram

I have this line of code:

ggplot(data=AB2, aes(AB2$logbm)) +
geom_histogram(breaks=seq(-1.5, 2.5, by=((max(AB2$logbm)-min(AB2$logbm))/7)))

And I have problem in trying to transform the unit of y axis - first I need to log it, with:


After that I want to divide all the values by
, then multiple by
. However with the above code, I dont seem to be able to adjust it with simply adding:
after the command.

Is there a way to tell
to do it??


Answer Source

You can do this, though not sure why you would want to, by using ..count.. in the aes

ggplot(AB2, aes(x = logbm)) +
  scale_y_log10() +
  geom_histogram(aes(y = ..count.. * 1.25 / 60))

NB no need to reference the data.frame in the aes.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download