d1 <- data.frame(x = runif(n = 10000, min = 0, max = 1), y =
rnorm(10000, sd = 0.2), type = "d1")
d2 <- data.frame(x = runif(n = 10000, min = 0, max = 1), y =
rnorm(10000, mean = 0.2, sd = 0.2), type = "d2")
all_d <- rbind(d1, d2)
ggplot(all_d, aes(x = x, y = y, color = type)) + geom_point()
Here you can see that d2
points are plotted over the d1
points. So I try changing things using forcats::fct_relevel
all_d_other <- all_d
all_d_other$type <- forcats::fct_relevel(all_d_other$type, "d2", "d1")
ggplot(all_d_other, aes(x = x, y = y, color = type)) + geom_point()
And d2
points are still on top of the d1
points. Is there a way to change it so that the d1
points are on top of the d2
points?