Last chance! 50% off unlimited learning
Sale ends in
spplot(obj, ...)
spplot.grid(obj, zcol = names(obj), ..., names.attr,
scales = list(draw = FALSE), xlab = NULL, ylab = NULL, aspect = mapasp(obj,xlim,ylim),
panel = panel.gridplot, sp.layout = NULL, formula, xlim = bbox(obj)[1, ],
ylim = bbox(obj)[2, ], checkEmptyRC = TRUE)
spplot.polygons(obj, zcol = names(obj), ..., names.attr,
scales = list(draw = FALSE), xlab = NULL, ylab = NULL, aspect = mapasp(obj,xlim,ylim),
panel = panel.polygonsplot, sp.layout = NULL, formula, xlim = bbox(obj)[1, ],
ylim = bbox(obj)[2, ])
spplot.points(obj, zcol = names(obj), ..., names.attr,
scales = list(draw = FALSE), xlab = NULL, ylab = NULL, aspect = mapasp(obj,xlim,ylim),
panel = panel.pointsplot, sp.layout = NULL, identify = FALSE, formula,
xlim = bbexpand(bbox(obj)[1, ], 0.04), ylim = bbexpand(bbox(obj)[2, ], 0.04))
mapLegendGrob(obj, widths = unit(1, "cm"), heights = unit(1, "cm"),
fill = "black", just = "right")
sp.theme(set = FALSE, regions = list(col = bpy.colors(100)), ...)
layout.north.arrow(type = 1)
layout.scale.bar(height = 0.05)
spplot.locator(n = 512, type = "n", ...)
list(draw = TRUE)
to draw axes scales; see xyplot for full optionsrow.names(as.data.frame(obj))
. If TRUE, identify
on panel (1,1)
; for identifyingz~x+y
for single and z~x+y|name
for multiple attributes; use
e.g. exp(x)~x+y|name
to plot the exponent of the z-variableprint(spplot(...))
. If identify
is TRUE,
the plot is plotted and the return value is a vector with row names of
the selected points.spplot.locator
returns a matrix with identified point locations;
use trellis.focus
first to focus on a given panel.
library(lattice)
trellis.par.set(sp.theme()) # sets bpy.colors() ramp
data(meuse)
coordinates(meuse) <- ~x+y
l2 = list("SpatialPolygonsRescale", layout.north.arrow(), offset = c(181300,329800),
scale = 400)
l3 = list("SpatialPolygonsRescale", layout.scale.bar(), offset = c(180500,329800),
scale = 500, fill=c("transparent","black"))
l4 = list("sp.text", c(180500,329900), "0")
l5 = list("sp.text", c(181000,329900), "500 m")
spplot(meuse, c("ffreq"), sp.layout=list(l2,l3,l4,l5), col.regions= "black",
pch=c(1,2,3), key.space=list(x=0.1,y=.95,corner=c(0,1)))
spplot(meuse, c("zinc", "lead"), sp.layout=list(l2,l3,l4,l5, which = 2),
key.space=list(x=0.1,y=.95,corner=c(0,1)))
# plotting factors:
meuse$f = factor(sample(letters[6:10], 155, replace=TRUE),levels=letters[1:10])
meuse$g = factor(sample(letters[1:5], 155, replace=TRUE),levels=letters[1:10])
spplot(meuse, c("f","g"), col.regions=bpy.colors(10))
if (require(RColorBrewer)) {
spplot(meuse, c("ffreq"), sp.layout=list(l2,l3,l4,l5),
col.regions=brewer.pal(3, "Set1"))
}
data(meuse.grid)
gridded(meuse.grid)=~x+y
meuse.grid$g = factor(sample(letters[1:5], 3103, replace=TRUE),levels=letters[1:10])
meuse.grid$f = factor(sample(letters[6:10], 3103, replace=TRUE),levels=letters[1:10])
spplot(meuse.grid, c("f","g"))
spplot(meuse.grid, c("f","g"), col.regions=bpy.colors(10))
Run the code above in your browser using DataLab