library(plyr) points <- seq(from = 0, to = 1, by = 0.01) grid_points <- merge(x = points, y = points) fixed_point_1 <- c(0.25, 0.75) fixed_point_2 <- c(1.00, 0.00) xyz <- ddply(grid_points, .(x, y), function(point) { data.frame( V1 = kernel(fixed_point_1, c(point$x, point$y)), V2 = kernel(fixed_point_2, c(point$x, point$y)) ) }) contour_matrix_1 <- matrix(xyz$V1 , nrow = length(points), byrow = TR