spaMM.filled.contour | R Documentation |
This function is derived from filled.contour
in the graphics
package, and
this documentation is likewise heavily based on that of filled.contour
.
This function likewise produces a contour plot with the areas between the
contours filled in solid color, and a
key showing how the colors map to z values is likewise shown to the right of
the plot.
The only difference is the way the aspect ratio is determined and can be controlled (using the map.asp
parameter instead of asp
),
They thus easily provide nice-looking maps with meaningful latitude/longitude ratio (see Examples). However, this does not work well with rstudio.
spaMM.filled.contour(x = seq(0, 1, length.out = nrow(z)),
y = seq(0, 1, length.out = ncol(z)),
z,
xrange = range(x, finite = TRUE),
yrange = range(y, finite = TRUE),
zrange = range(z, finite = TRUE, na.rm=TRUE),
margin=1/20,
levels = pretty(zrange, nlevels), nlevels = 20,
color.palette = spaMM.colors,
col = color.palette(length(levels) - 1),
plot.title, plot.axes, key.title=NULL, key.axes=NULL,
map.asp = NULL, xaxs = "i", yaxs = "i", las = 1,
axes = TRUE, frame.plot = axes, ...)
x , y |
locations of grid lines at which the values in |
z |
a numeric matrix containing the values to be plotted.. Note that
|
xrange |
x range of the plot. |
yrange |
y range of the plot. |
zrange |
z range of the plot. |
margin |
This controls how far (in relative terms) the plot extends beyond the x and y ranges
of the analyzed points, and is overriden by explicit |
levels |
a set of levels which are used to partition the range
of |
nlevels |
if |
color.palette |
a color palette function to be used to assign colors in the plot. |
col |
an explicit set of colors to be used in the plot. This argument overrides any palette function specification. There should be one less color than levels |
plot.title |
statements which add titles to the main plot. |
plot.axes |
statements which draw axes (and a |
key.title |
statements which add titles for the plot key. |
key.axes |
statements which draw axes on the plot key. This overrides the default axis. |
map.asp |
the y/x aspect ratio of the 2D plot area (not of the full figure including the scale). Default is (plotted y range)/(plotted x range) (i.e., scales for x are identical). |
xaxs |
the x axis style. The default is to use internal labeling. |
yaxs |
the y axis style. The default is to use internal labeling. |
las |
the style of labeling to be used. The default is to use horizontal labeling. |
axes , frame.plot |
logicals indicating if axes and a box should be
drawn, as in |
... |
additional graphical parameters, currently only passed to
|
The values to be plotted can contain NA
s. Rectangles with two
or more corner values are NA
are omitted entirely: where there
is a single NA
value the triangle opposite the NA
is
omitted.
Values to be plotted can be infinite: the effect is similar to that
described for NA
values.
This returns invisibly a list with elements of the plot, the x
, y
, z
coordinates and the contour levels
.
Builds heavily on filled.contour by Ross Ihaka and R-core.
spaMM.filled.contour
uses the layout
function and so is
restricted to a full page display.
The output produced by spaMM.filled.contour
is actually a combination
of two plots; one is the filled contour and one is the legend. Two
separate coordinate systems are set up for these two plots, but they
are only used internally – once the function has returned these
coordinate systems are lost. If you want to annotate the main contour
plot, for example to add points, you can specify graphics commands in
the plot.axes
argument. See the Examples.
Cleveland, W. S. (1993) Visualizing Data. Summit, New Jersey: Hobart.
contour
, image
,
palette
; contourplot
and levelplot
from package lattice
.
spaMM.filled.contour(volcano, color.palette = spaMM.colors) # simple
## Comparing the layout with that of filled.contour:
# (except that it does not always achieve the intended effect
# in RStudio Plots pane).
x <- 10*1:nrow(volcano)
y <- 10*1:ncol(volcano)
spaMM.filled.contour(x, y, volcano, color.palette = terrain.colors,
plot.title = title(main = "The Topography of Maunga Whau",
xlab = "Meters North", ylab = "Meters West"),
plot.axes = { axis(1, seq(100, 800, by = 100))
axis(2, seq(100, 600, by = 100)) },
key.title = title(main = "Height\n(meters)"),
key.axes = axis(4, seq(90, 190, by = 10))) # maybe also asp = 1
mtext(paste("spaMM.filled.contour(.) from", R.version.string),
side = 1, line = 4, adj = 1, cex = .66)
## compare with
filled.contour(x, y, volcano, color.palette = terrain.colors,
plot.title = title(main = "The Topography of Maunga Whau",
xlab = "Meters North", ylab = "Meters West"),
plot.axes = { axis(1, seq(100, 800, by = 100))
axis(2, seq(100, 600, by = 100)) },
key.title = title(main = "Height\n(meters)"),
key.axes = axis(4, seq(90, 190, by = 10))) # maybe also asp = 1
mtext(paste("filled.contour(.) from", R.version.string),
side = 1, line = 4, adj = 1, cex = .66)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.