simage
(generic function) draws an image (a grid
of colored rectangles) and (optionally) adds a legend
strip with the color scale (calls splot
and
image
). plot.np.den
calls simage.data.grid
(contour
and points
also by
default).
simage(x, ...)
"simage" (x = seq(0, 1, len = nrow(s)), y = seq(0, 1, len = ncol(s)), s, slim = range(s, finite = TRUE), col = jet.colors(128), breaks = NULL, legend = TRUE, horizontal = FALSE, legend.shrink = 0.8, legend.width = 1.2, legend.mar = ifelse(horizontal, 3.1, 5.1), legend.lab = NULL, bigplot = NULL, smallplot = NULL, lab.breaks = NULL, axis.args = NULL, legend.args = NULL, graphics.reset = FALSE, xlab = NULL, ylab = NULL, ...)
"simage" (x, data.ind = 1, xlab = NULL, ylab = NULL, ...)
"plot" (x, y = NULL, log = TRUE, contour = TRUE, points = TRUE, col = hot.colors(128), ...)
x
coordinate. If x
is a list, its components x$x
and x$y
are
used for x
and y
, respectively. For
compatibility with image
, if the list has
component z
this is used for s
.y
coordinate.x
can be used instead of s
for
convenience.TRUE
(default), the
plotting region is splitted into two parts, drawing the
image plot in one and the legend with the color scale in
the other. If FALSE
only the image plot is drawn
and the arguments related to the legend are ignored
(splot
is not called).image
or simage.default
; e.g.
xlim, ylim,
...). NOTE: graphical arguments passed
here will only have impact on the main plot. To change
the graphical defaults for the legend use the
par
function beforehand (e.g.
par(cex.lab = 2)
to increase colorbar labels).TRUE
(default),
log(x$est)
is ploted.TRUE
(default), contour
lines are added.TRUE
(default), points
at x$data$x
are drawn.image
for details).col
and be in increasing order.FALSE
(default)
legend will be a vertical strip on the right side. If
TRUE
the legend strip will be along the bottom.image.plot
for details).mtext
function. Usually
this will not be needed (see
image.plot
for details).FALSE
(default)
the plotting region (par("plt")
) will not
be reset to make it possible to add more features to the
plot (e.g. using functions such as points or lines). If
TRUE
will reset plot parameters to the values
before entering the function.x
.y
.par(old.par)
will reset plot
parameters to the values before entering the function).par("plt")
) to make it possible to add
more features to the plot (set graphics.reset =
FALSE
to avoid this).splot
, spoints
,
spersp
, image
,
image.plot
,
data.grid
.
#
# Regularly spaced 2D data
nx <- c(40, 40) # ndata = prod(nx)
x1 <- seq(-1, 1, length.out = nx[1])
x2 <- seq(-1, 1, length.out = nx[2])
trend <- outer(x1, x2, function(x,y) x^2 - y^2)
simage( x1, x2, trend, main = 'Trend')
#
# Multiple plots
set.seed(1)
y <- trend + rnorm(prod(nx), 0, 0.1)
x <- as.matrix(expand.grid(x1 = x1, x2 = x2)) # two-dimensional grid
# local polynomial kernel regression
lp <- locpol(x, y, nbin = nx, h = diag(c(0.3, 0.3)))
# 1x2 plot
old.par <- par(mfrow = c(1,2))
simage( x1, x2, y, main = 'Data')
simage(lp, main = 'Estimated trend')
par(old.par)
Run the code above in your browser using DataLab