当我使用geom_density_ridges()
,该图通常最终会显示数据中不存在的值的长尾。
这是一个例子:
library(tidyverse)
library(ggridges)
data("lincoln_weather")
# Remove all negative values for "Minimum Temperature"
d <- lincoln_weather[lincoln_weather$`Min Temperature [F]`>=0,]
ggplot(d, aes(`Min Temperature [F]`, Month)) +
geom_density_ridges(rel_min_height=.01)
As you can see, January, February, and December all show negative temperatures, but there are no negative values in the data at all.
当然,我可以对 x 轴添加限制,但这并不能解决问题,因为它只是截断了现有的错误密度。
ggplot(d, aes(`Min Temperature [F]`, Month)) +
geom_density_ridges(rel_min_height=.01) +
xlim(0,80)
Now the plot makes it look like there are zero values for January and February (there are none). It also makes it look like 0 degrees happened often in December, when in reality there was only 1 such day.
我怎样才能解决这个问题?