The function is a wrapper for the image() function, but with a comfortable
control of the z-axis and its color legend. The wrapper also supports image
resizing (resolution) and png output for better export.
rasterImage2(x = NULL, y = NULL, z, zlim = NULL, xlim = NULL,
ylim = NULL, dim.max = NULL, plot.zero.line = T, regularGrid = T,
zlab = NULL, z.cex = 0.5, z.adj = c(0.5, 0.5), z.format = "fg",
ndz = 7, ncolors = 256, palette = "spectral", palette.inv = F,
...)x-axis vector corresponding to the z-matrix
y-axis vector corresponding to the z-matrix
numeric matrix to be plotted
sets the range of the color coded z-axis
the x limits (x1, x2) of the plot. Note that x1 > x2
is allowed and leads to a ‘reversed axis’.
The default value, NULL, indicates that the range of the
finite values to be plotted should be used.
the y limits of the plot.
defines the dimensions of the visible area of z. It automatically invokes a rescale. In case of large data sets this parameter can improve plotting speed.
logical, if a line at x = 0 and y = 0 is
to be plotted.
logical, if FALSE then a vector plot is generated,
which is the slow and standard behaviour of image.
If this parameter is TRUE then a raster image is
generated, which can be processed much faster, compared to
the FALSE option.
defines the z-label
cex value for the z-label. It sets the font size in relation to
the global par()$cex value
a two component vector. It sets the left/right and top/bottom justification
controls how the numbers besides the color scale are composed.
It works like the format option of formatC
sets the axis breaks right to the color scale
number of colors to use in the plot
defines the color palette to be used in the plot
logical, if TRUE reverts the color palette
further arguments to the plot function, e.g. 'xlab'
The regularGrid option forces interpolation in case of irregular spacing
of x or y. All data is then projected on a regular grid.
This correction invokes a spline interpolation. Missing NA values
are ignored.
# NOT RUN {
rasterImage2( z = volcano, palette = "spectral", dim.max = c(500,100)
,zlab = "Height", z.adj = c(0,1) ,z.cex = 1
,main = "Volcano Data Set"
)
# }
Run the code above in your browser using DataLab