【发布时间】:2020-04-13 16:23:13
【问题描述】:
假设我们做一个直方图
set.seed(123)
x = rnorm(1000)
qplot(x, geom = 'blank') +
geom_histogram()
我们添加了一条密度线
qplot(x, geom = 'blank') +
geom_histogram() +
geom_density()
密度线太低了,很难看到,所以可以是scaled to match the height of the histogram:
qplot(x, geom = 'blank') +
geom_histogram(bins = 30) +
geom_density(aes(y=0.22 * ..count..))
问题
当不使用binwidth 参数到geom_histogram 时(即使用bins 参数时),我们如何以编程方式调整密度线。
所需的输出是一个geom_histogram(bins = ...),具有明显缩放的密度线,不依赖于乘数/硬编码的任何手动计算。
【问题讨论】: