library(ggplot2)
library(hexbin)
dat <- within(data.frame(x = rnorm(10000), y = rnorm(10000)), {
Distance <- sqrt(x^2 + y^2)
})
ggplot(dat, aes(x = x, y = y)) +
geom_hex() + coord_fixed() +
scale_fill_gradientn(colours = viridis(256))Run the code above in your browser using DataLab