imagep {oce} | R Documentation |
Plot an image with a colour palette, in a way that does not conflict with
par(mfrow)
or layout
. To plot just a palette,
e.g. to get an x-y plot with points coloured according to a palette, use
drawPalette
and then draw the main diagram.
imagep(x, y, z, xlim, ylim, zlim, zclip = FALSE, flipy = FALSE, xlab = "", ylab = "", zlab = "", zlabPosition = c("top", "side"), decimate = TRUE, breaks, col, colormap, labels = NULL, at = NULL, drawContours = FALSE, drawPalette = TRUE, drawTriangles = FALSE, tformat, drawTimeRange = getOption("oceDrawTimeRange"), filledContour = FALSE, missingColor = NULL, useRaster, mgp = getOption("oceMgp"), mar, mai.palette, xaxs = "i", yaxs = "i", asp = NA, cex = par("cex"), axes = TRUE, main = "", axisPalette, add = FALSE, debug = getOption("oceDebug"), ...)
x, y |
These have different meanings in different modes of operation.
Mode 1. One
mode has them meaning the locations of coordinates along which values
matrix |
z |
A matrix containing the values to be plotted (NAs are allowed). Note
that x can be used instead of z for convenience. (NOTE: these arguments
are meant to mimic those of |
xlim, ylim |
Limits on x and y axes. |
zlim |
If missing, the z scale is determined by the range of the data.
If provided, |
zclip |
Logical, indicating whether to clip the colours to those
corresponding to |
flipy |
Logical, with |
xlab, ylab, zlab |
Names for x axis, y axis, and the image values. |
zlabPosition |
String indicating where to put the label for the z axis, either at the top-right of the main image, or on the side, in the axis for the palette. |
decimate |
Controls whether the image will be decimated before plotting,
in three possible cases. Case 1.
If |
breaks |
The z values for breaks in the colour scheme. If this is of
length 1, the value indicates the desired number of breaks, which is
supplied to |
col |
Either a vector of colours corresponding to the breaks, of length
1 plus the number of breaks, or a function specifying colours,
e.g. |
colormap |
A colour map as created by |
labels |
Optional vector of labels for ticks on palette axis (must
correspond with |
at |
Optional vector of positions for the |
drawContours |
Logical value indicating whether to draw contours on the image, and palette, at the colour breaks. Images with a great deal of high-wavenumber variation look poor with contours. |
drawPalette |
Indication of the type of palette to draw, if any. If
|
drawTriangles |
Logical value indicating whether to draw
triangles on the top and bottom of the palette. This is passed to
|
tformat |
Optional argument passed to |
drawTimeRange |
Logical, only used if the |
filledContour |
Boolean value indicating whether to use filled contours to plot the image. |
missingColor |
A colour to be used to indicate missing data, or
|
useRaster |
A logical value passed to |
mgp |
A 3-element numerical vector to use for |
mar |
A 4-element Value to be used with |
mai.palette |
Palette margin corrections (in inches), added to the
|
xaxs |
Character indicating whether image should extend to edge
of x axis (with value |
yaxs |
As |
asp |
Aspect ratio of the plot, as for |
cex |
Size of labels on axes and palette; see |
axes |
Logical, set |
main |
Title for plot. |
axisPalette |
Optional replacement function for |
add |
Logical value indicating whether to add to an existing plot.
The default value, |
debug |
A flag that turns on debugging. Set to 1 to get a moderate amount of debugging information, or to 2 to get more. |
... |
Optional arguments passed to plotting functions. |
By default, creates an image with a colour palette to the right. The effect is similar to
filled.contour
except that with imagep
it is possible to
set the layout
outside the function, which enables the creation
of plots with many image-palette panels. Note that the contour lines may not
coincide with the colour transitions, in the case of coarse images.
Note that this does not use layout
or any of the other screen
splitting methods. It simply manipulates margins, and draws two plots
together. This lets users employ their favourite layout schemes.
NOTE: imagep
is an analogue of image
, and from that
it borrows a the convention that the number of rows in the matrix corresponds to
to x
axis, not the y
axis. (Actually, image
permits
the length of x
to match either nrow(z)
or 1+nrow(z)
, but
here only the first is permitted.)
A list is silently returned, containing xat
and yat
,
values that can be used by oce.grid
to add a grid to the
plot.
Dan Kelley and Clark Richards
This uses drawPalette
, and is used by plot,adp-method
,
plot,landsat-method
, and other image-generating functions.
library(oce) # 1. simplest use imagep(volcano) # 2. something oceanographic (internal-wave speed) h <- seq(0, 50, length.out=100) drho <- seq(1, 3, length.out=200) speed <- outer(h, drho, function(drho, h) sqrt(9.8 * drho * h / 1024)) imagep(h, drho, speed, xlab="Equivalent depth [m]", ylab=expression(paste(Delta*rho, " [kg/m^3]")), zlab="Internal-wave speed [m/s]") # 3. fancy labelling on atan() function x <- seq(0, 1, 0.01) y <- seq(0, 1, 0.01) angle <- outer(x,y,function(x,y) atan2(y,x)) imagep(x, y, angle, filledContour=TRUE, breaks=c(0, pi/4, pi/2), col=c("lightgray", "darkgray"), at=c(0, pi/4, pi/2), labels=c(0, expression(pi/4), expression(pi/2))) # 4. a colormap case data(topoWorld) cm <- colormap(name="gmt_globe") imagep(topoWorld, colormap=cm)