sp_plot | R Documentation |
Lattice (trellis) plot methods for spatial data with attributes
sp_plot(
grid,
df = grid@data,
zcols,
formula = NULL,
df.mask = NULL,
brks,
cols,
strip = FALSE,
strip.factors = NULL,
toFactor = FALSE,
panel.titles_full = NULL,
panel = panel.spatial,
xlim = NULL,
ylim = NULL,
unit = "",
unit.adj = 0.3,
area.weighted = FALSE,
colorkey = TRUE,
key.space = "right",
key.height = 0.98,
key.num2factor = FALSE,
interpolate = FALSE,
lgd.title = NULL,
sp.layout = NULL,
layout = NULL,
NO_begin = 1,
cex.lgd = 1.3,
par.strip.text = NULL,
par.settings = opt_trellis_default,
par.settings2 = list(axis.line = list(col = "transparent")),
...
)
df |
data.table object, with columns e.g. lon, lat, and others |
formula |
a formula of the form z ~ s1 + s2 | g1 * g2 * ..., where z is a numeric response, and x, y are numeric values evaluated on a rectangular grid. g1, g2, ... are optional conditional variables, and must be either factors or shingles if present. |
df.mask |
NULL or same length data.table as df, with the columns of |
brks |
either a numeric vector of two or more unique cut points to convert values in df into factor. |
cols |
corresponding colors of every break interval |
panel.titles_full |
string or expression vectors of panel titles, default NULL.
If provided, group names in |
panel |
panel function used to create the display, as described in
|
xlim , ylim |
The limits of x and y |
colorkey |
Boolean or list returned by |
sp.layout |
NULL or list; see notes below |
NO_begin |
beginning NO of the first panel |
... |
Further arguments may be supplied. Some are processed by
|
pars |
parameters controlling the position of histogram and panel titles,
e.g. |
SpatialPixel |
corresponding SpatialPixel object of If |
parameter panel.title
change to panel.titles_full
panel.titles_full
is for tags.
strip.factors
is for strip factors
sp::spplot()
, lattice::levelplot()
library(Ipaper)
library(lattice)
set_font()
data("grid_avhrr")
pars = list(title = list(x=77, y=39, cex=1.2))
trellis.par.set("add.text" = list(fontfamily = get_family(), cex = 2))
p <- sp_plot(grid_avhrr,
pars = pars,
interpolate = FALSE) +
layer_barchart(x = 0.05, y = 0.15, width = 0.25) +
layer_latFreq(zlim_ratio = c(0, 1), bbox = c(0.8, 1, 0, 1)) +
layer_statistic(x = 0.5, y = 0.6, FUN = weightedMedian) +
layer_signPerc(x = 0.05, y = 0.6) +
layer_signDist()
write_fig(p, show = FALSE)
# write_fig(p, "ex-sp_plot1.pdf", 9.8, 5)
## levelplot stype
df = grid_avhrr@data %>% data.frame() %>%
list(a = ., b = .) %>% melt_list("type")
sp_plot(grid_avhrr, df,
formula = X1982 ~ lon+lat | type,
aspect = 0.5, pars = pars) +
layer_barchart(x = 0.05, y = 0.15, width = 0.25) +
layer_latFreq(zlim_ratio = c(0, 1), bbox = c(0.9, 1, 0, 1)) +
layer_statistic(x = 0.5, y = 0.6, FUN = weightedMedian) +
layer_signPerc(x = 0.05, y = 0.6) +
layer_signDist()
# write_fig(p2 , "ex-sp_plot2.pdf", 6, 5)
## show strip
sp_plot(grid_avhrr, df, zcols = 2,
# formula = X1982 ~ lon+lat | type,
strip = TRUE,
par.settings2 = list(axis.line = list(col = "black")),
aspect = 0.5, pars = pars)
# write_fig(p3 , "ex-sp_plot3.pdf", 6, 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.