epidataCS_plot | R Documentation |
The plot
method for class "epidataCS"
either plots the
number of events along the time axis (epidataCSplot_time
) as a
hist()
, or the locations of the events in the observation region
W
(epidataCSplot_space
).
The spatial plot can be enriched with tile-specific color levels to
indicate attributes such as the population (using spplot
).
## S3 method for class 'epidataCS'
plot(x, aggregate = c("time", "space"), subset, by = type, ...)
epidataCSplot_time(x, subset, by = type,
t0.Date = NULL, breaks = "stgrid", freq = TRUE,
col = rainbow(nTypes), cumulative = list(),
add = FALSE, mar = NULL, xlim = NULL, ylim = NULL,
xlab = "Time", ylab = NULL, main = NULL,
panel.first = abline(h=axTicks(2), lty=2, col="grey"),
legend.types = list(), ...)
epidataCSplot_space(x, subset, by = type, tiles = x$W, pop = NULL,
cex.fun = sqrt, points.args = list(), add = FALSE,
legend.types = list(), legend.counts = list(),
sp.layout = NULL, ...)
x |
an object of class |
aggregate |
character, one of |
subset |
logical expression indicating a subset of events to consider for
plotting: missing values are taken as false. Note that the
expression is evaluated in the data frame of event marks
( |
... |
in the basic |
by |
an expression evaluated in |
t0.Date |
the beginning of the observation period
|
breaks |
a specification of the histogram break points, see
|
freq |
see |
col |
fill colour for the bars of the histogram, defaults to
the vector of |
cumulative |
if a list (of style options),
lines for the cumulative number of events (per type) will be
added to the plot. Possible options are |
add |
logical (default: |
mar |
see |
xlim , ylim |
|
xlab , ylab |
axis labels (with sensible defaults). |
main |
main title of the plot (defaults to no title). |
panel.first |
expression that should be evaluated after the plotting window has been set up but before the histogram is plotted. Defaults to adding horizontal grid lines. |
legend.types |
if a list (of arguments for |
tiles |
the observation region |
pop |
if |
cex.fun |
function which takes a vector of counts of events
at each unique location and returns a (vector of) |
points.args |
a list of (type-specific) graphical parameters
for |
legend.counts |
if a list (of arguments for
|
sp.layout |
optional list of additional layout items in case
|
For aggregate="time"
(i.e., epidataCSplot_time
) the data
of the histogram (as returned by hist
),
and for aggregate="space"
(i.e., epidataCSplot_space
)
NULL
, invisibly, or the trellis.object
generated by
spplot
(if pop
is non-NULL
).
Sebastian Meyer
animate.epidataCS
data("imdepi")
## show the occurrence of events along time
plot(imdepi, "time", main = "Histogram of event time points")
plot(imdepi, "time", by = NULL, main = "Aggregated over both event types")
## show the distribution in space
plot(imdepi, "space", lwd = 2, col = "lavender")
## with the district-specific population density in the background,
## a scale bar, and customized point style
load(system.file("shapes", "districtsD.RData", package = "surveillance"))
districtsD$log10popdens <- log10(districtsD$POPULATION/districtsD$AREA)
keylabels <- (c(1,2,5) * rep(10^(1:3), each=3))[-1]
plot(imdepi, "space", tiles = districtsD, pop = "log10popdens",
## modify point style for better visibility on gray background
points.args = list(pch=c(1,3), col=c("orangered","blue"), lwd=2),
## metric scale bar, see proj4string(imdepi$W)
sp.layout = layout.scalebar(imdepi$W, scale=100, labels=c("0","100 km")),
## gray scale for the population density and white borders
col.regions = gray.colors(100, start=0.9, end=0.1), col = "white",
## color key is equidistant on log10(popdens) scale
at = seq(1.3, 3.7, by=0.05),
colorkey = list(labels=list(at=log10(keylabels), labels=keylabels),
title=expression("Population density per " * km^2)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.