Density Contour Plot

Density contour lines are two-dimensional Density Curves. So the relationship between density contour lines and Heatmaps is like that between Density Curves and Histograms.

Density contour plots use kernel density estimates to calculate the curves.

Implementation

library(GDAdata)
library(MASS)
f1 <- kde2d(SpeedSki$Year, SpeedSki$Speed, n = 100)
image(f1)
contour(f1, add = T)
library(GDAdata)
ggplot(SpeedSki, aes(Year, Speed)) +
    geom_density_2d() +
    geom_density_2d_filled(alpha = 0.7)
ggplot(con2tr(f1, aes(x, y)) + geom_contour(aes(z = z))
Creative Commons License by zcysxy