I want to draw the density line on the scatter plot using ggplot2.
Referencing this code, I draw the example figure below:
set.seed(1)
df <- data.frame(x = rnorm(200), y = rnorm(200))
ggplot(df, aes(x = x, y = y)) +
geom_point() +
geom_density_2d()
The expected result is here.