我的密度图看起来像这样:
> ggplot(data, aes(diff)) + geom_density()
我的目标是仅填写y = 0及以下的线下方区域。我曾试过geom_ribbon()
,但只能填满整个区域。怎么会只填充x = 0?
示例数据:
> dput(data)
c(-4.93, 2.19, -1.82, 3.06, 9.13, 5.72, 5.5, 0.85, 2.99, 8.04,
3.59, -5.12, -0.03, 6.98, 6.79, 6.59, 1.25, -4.12, -2.34, -3.21,
-3.52, 4.22, 0.98, 10.38, 1.34, 1, 2.27, -1.41, -1.64, -2.31,
1.81, -6.16, 2.89, 1.94, 0.03, 3.76, 6.39, 3.02, -2.44, -0.39,
0.66, 9.93, 2.23, 3.78, 1.39, 1.82, -2.91, -0.17, 1.66, 6.91,
-0.31, 0.87, -2.23, 2.37, 0.62, 0.07, 1.77, -2.13, -2.27, 2.59,
3.42, 11.65, -3.7, -4.61, 8.14, -0.74, 1.37, 5.44, 5.53, 6.01,
-0.31, -2.42, -6.15, 4.81, 0.37, 3.21, 7.43, 11.54, 6.06, 4.47,
1.52, 7.69, 4.51, -0.58, -10.34, -2.36, 6.82, 6.55, 11.63, 0.49,
-3.27, 4.09, 5.51, 3.23, 4.32, 0.02, 5.57, 7.93, -7.56, 7.57)