我有一个简短的 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))