d <- ggplot(diamonds, aes(carat, depth, z = price))
d + stat_summary_2d()
# Specifying function
d + stat_summary_2d(fun = function(x) sum(x^2))
d + stat_summary_2d(fun = var)
d + stat_summary_2d(fun = "quantile", fun.args = list(probs = 0.1))
if (requireNamespace("hexbin")) {
d + stat_summary_hex()
}
Run the code above in your browser using DataLab