I have a short R script which plots a few histograms using ggplot2. How can I automatically set the ymax limit in the histogram based on the maximum frequency in the histogram (plus 10%) i.e
scale_y_continuous(limits= c(0,ymax*1.1)
plot = ggplot(data, aes(myo_activity)) +
geom_histogram(binwidth=0.5, aes(fill=..count..))
plot + scale_x_continuous(expand = c(0,0), limits = c(30,90)) +
scale_y_continuous(expand = c(0,0), limits = c(0,140))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…