我有一个简短的R脚本,使用ggplot2绘制一些直方图.如何根据直方图中的最大频率(加10%)自动设置直方图中的ymax限制,即
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))
Run Code Online (Sandbox Code Playgroud)