I want to draw a segment below a density plot and I would like to have the distance be a constant number of pixels. Is this possible? I Know how to hardcode the distance. For example:
set.seed(40816)
library(ggplot2)
df.plot <- data.frame(x = rnorm(100, 0, 1))
ggplot(df.plot, aes(x = x)) + geom_density() +
geom_segment(aes(x = -1, y = -0.05, xend = 1, yend = -0.05),
linetype = "longdash")
produces :
But
df.plot <- data.frame(x = rnorm(100, 0, 4))
ggplot(df.plot, aes(x = x)) + geom_density() +
geom_segment(aes(x = -1, y = -0.025, xend = 1, yend = -0.025),
linetype = "longdash")
produces a plot with the segment much further away from the density