This function is very similar to the
image
function. It works with every loon plot which
is based on the cartesian coordinate system.
Arguments
- widget
widget path as a string or as an object handle
- x
locations of grid lines at which the values in z are measured. These must be finite, non-missing and in (strictly) ascending order. By default, equally spaced values from 0 to 1 are used. If x is a list, its components x$x and x$y are used for x and y, respectively. If the list has component z this is used for z.
- y
see description for the
x
argument above- z
a numeric or logical matrix containing the values to be plotted (
NA
s are allowed). Note thatx
can be used instead ofz
for convenience.- zlim
the minimum and maximum
z
values for which colors should be plotted, defaulting to the range of the finite values ofz
. Each of the given colors will be used to color an equispaced interval of this range. The midpoints of the intervals cover the range, so that values just outside the range will be plotted.- xlim
range for the plotted x values, defaulting to the range of x
- ylim
range for the plotted y values, defaulting to the range of y
- col
a list of colors such as that generated by
hcl.colors
,gray.colors
or similar functions.- breaks
a set of finite numeric breakpoints for the colours: must have one more breakpoint than colour and be in increasing order. Unsorted vectors will be sorted, with a warning.
- oldstyle
logical. If true the midpoints of the colour intervals are equally spaced, and
zlim[1]
andzlim[2]
were taken to be midpoints. The default is to have colour intervals of equal lengths between the limits.- useRaster
logical; if
TRUE
a bitmap raster is used to plot the image instead of polygons. The grid must be regular in that case, otherwise an error is raised. For the behaviour when this is not specified, see ‘Details’.- index
position among its siblings. valid values are 0, 1, 2, ..., 'end'
- 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 liketkpack
ortkplace
in order to be displayed. See the examples below.- ...
argumnets forwarded to
l_layer_line
Examples
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))
}