# NOT RUN {
if(interactive()){
if (requireNamespace("MASS", quietly = TRUE)) {
kest <- with(iris, MASS::kde2d(Sepal.Width,Sepal.Length))
image(kest)
contour(kest, add=TRUE)
p <- l_plot()
lcl <- l_layer_contourLines(p, kest, label='contour lines')
limg <- l_layer_heatImage(p, kest, label='heatmap')
l_scaleto_world(p)
}
# from examples(image)
x <- y <- seq(-4*pi, 4*pi, len = 27)
r <- sqrt(outer(x^2, y^2, "+"))
p1 <- l_plot()
l_layer_heatImage(p1, z = z <- cos(r^2)*exp(-r/6), col = gray((0:32)/32))
l_scaleto_world(p1)
image(z = z <- cos(r^2)*exp(-r/6), col = gray((0:32)/32))
}
# }
Run the code above in your browser using DataLab