Hello experts. I'm looking for a ggplot2 plotting function (i.e., geom_something) that can clearly show the relationship between two variables when there are so many data points that geom_point() isn't a good option due to extensive point overlap. Specifically, I'm looking for a ggplot2 function to create this type of plot.
Is there one? If not, any advice will be very welcome!
Thank you! I checked these functions. Unfortunately it seems they don't have any option for "smoothing out" the borders of rectangles/hexagons. As a result, plots created by these functions show a mosaic pattern with many "empty" hexagons/rectangles, which make them aesthetically not good. Is it not possible to create the example plot (exactly as it is) with ggplot2?
KDE <- MASS::kde2d(x = DF$X, y = DF$Y, n = 100)
DFnew <- data.frame(X = rep(KDE$x, 100), Y = rep(KDE$y, each = 100),
Z = as.vector(KDE$z))
ggplot(DFnew, aes(x = X, y = Y, z = Z)) + geom_contour_filled()