There probably is an obvious solution to this, but I'm a bit naive with plotting. I'd like to have point_shape
and point_fill
defined manually to indicate e.g. gender groups. How would I go about doing this?
In other words, I'd like to see e.g. green squares for females and blue triangles for non-females (as an arbitrary example). (A commenter mentioned that there are no points on the plot, but there are when using the current development version of ggridges.)
# Simulate data:
df <- data.frame(female = factor(sample(0:1, size = 500, replace = TRUE)),
intervention = factor(sample(0:1, size = 500, replace = TRUE))) %>%
dplyr::mutate(value = ifelse(female == "1", runif(n = 500, min = 0, max = 100),
rnorm(n = 500, mean = 50, sd = 20)))
# Draw plot:
df %>%
ggplot2::ggplot(aes(y = intervention)) +
ggridges::geom_density_ridges2(aes(x = value,
colour = "black",
fill = female),
scale = .7,
alpha = 0.6,
size = 0.25,
jittered_points = TRUE,
point_shape = 21,
point_size = 0.85,
point_fill = "black")