This function is a wrapper around
contourLines that adds the countourlines to a loon
plot which is based on the cartesian coordinate system.
Arguments
- widget
widget path as a string or as an object handle
- x, y
As described in
grDevices::contourLines: locations of grid lines at which the values in z are measured. These must be in ascending order. By default, equally spaced values from 0 to 1 are used. Ifxis a list, its componentsx$xandx$yare used forxandy, respectively. If the list has componentzthis is used forz.- z
As described in
grDevices::contourLines: a matrix containing the values to be plotted (NAs are allowed). Note thatxcan be used instead ofzfor convenience.- nlevels
As described in
grDevices::contourLines: number of contour levels desired ifflevelsis not supplied.- levels
As described in
grDevices::contourLines: numeric vector of levels at which to draw contour lines.- asSingleLayer
if
TRUEa lines layer is used for the line, otherwise ifFALSEa group with nested line layers for each line is created- parent
a valid Tk parent widget path. When the parent widget is specified (i.e. not
NULL) then the plot widget needs to be placed using some geometry manager liketkpackortkplacein order to be displayed. See the examples below.- index
position among its siblings. valid values are 0, 1, 2, ..., 'end'
- ...
arguments forwarded to
l_layer_line
Examples
if(interactive()){
p <- l_plot()
x <- 10*1:nrow(volcano)
y <- 10*1:ncol(volcano)
lcl <- l_layer_contourLines(p, x, y, volcano)
l_scaleto_world(p)
if (requireNamespace("MASS", quietly = TRUE)) {
p1 <- with(iris, l_plot(Sepal.Length~Sepal.Width, color=Species))
lcl <- with(iris, l_layer_contourLines(p1, MASS::kde2d(Sepal.Width,Sepal.Length)))
p2 <- with(iris, l_plot(Sepal.Length~Sepal.Width, color=Species))
layers <- sapply(split(cbind(iris, color=p2['color']), iris$Species), function(dat) {
kest <- with(dat, MASS::kde2d(Sepal.Width,Sepal.Length))
l_layer_contourLines(p2, kest, color=as.character(dat$color[1]), linewidth=2,
label=paste0(as.character(dat$Species[1]), " contours"))
})
}
}
