Usage
scatterPlot(mydata, x = "nox", y = "no2", z = NA, method = "scatter",
group = NA, avg.time = "default", data.thresh = 0, statistic = "mean",
percentile = NA, type = "default", smooth = FALSE, spline = FALSE,
linear = FALSE, ci = TRUE, mod.line = FALSE, cols = "hue",
plot.type = "p", key = TRUE, key.title = group, key.columns = 1,
key.position = "right", strip = TRUE, log.x = FALSE, log.y = FALSE,
x.inc = NULL, y.inc = NULL, limits = NULL, y.relation = "same",
x.relation = "same", ref.x = NULL, ref.y = NULL, k = 100,
dist = 0.1, map = FALSE, auto.text = TRUE, ...)
Arguments
mydata
A data frame containing at least two numeric variables to
plot.
x
Name of the x-variable to plot. Note that x can be a date field or
a factor. For example, x
can be one of the openair
built in
types such as "year"
or "season"
.
y
Name of the numeric y-variable to plot.
z
Name of the numeric z-variable to plot for method =
"scatter"
or method = "level"
. Note that for method =
"scatter"
points will be coloured according to a continuous colour
scale, whereas for method = "level
method
Methods include scatter (conventional scatter plot),
hexbin (hexagonal binning using the hexbin
package).
level for a binned or smooth surface plot and density (2D
kernel
group
The grouping variable to use, if any. Setting this to a
variable in the data frame has the effect of plotting several series in
the same panel using different symbols/colours etc. If set to a variable
that is a character or factor, those categories or
avg.time
This defines the time period to average to. Can be
sec, min, hour, day,
DSTday, week, month, quarter
or year
data.thresh
The data capture threshold to use (the data using avg.time
. A value of zero means that all available
data will be used in a particular period regardless if of the number of
values available. Conversely, a value of 100 will mean that all dat
statistic
The statistic to apply when aggregating the data; default
is the mean. Can be one of "mean", "max", "min", "median", "frequency",
"sd", "percentile". Note that "sd" is the standard deviation and
"frequency" is the number (frequency) of valid records in
percentile
The percentile level in % used when statistic =
"percentile"
and when aggregating the data with avg.time
. The
default is 95. Not used if avg.time = "default"
.
type
type
determines how the data are split
i.e. conditioned, and then plotted. The default is will produce a
single plot using the entire data. Type can be one of the built-in
types as detailed in cutData
e.g. season
smooth
A smooth line is fitted to the data if TRUE
;
optionally with 95% confidence intervals shown. For method =
"level"
a smooth surface will be fitted to binned data.
spline
A smooth spline is fitted to the data if TRUE
. This is
particularly useful when there are fewer data points or when a connection
line between a sequence of points is required.
linear
A linear model is fitted to the data if TRUE
;
optionally with 95% confidence intervals shown. The equation of the line
and R2 value is also shown.
ci
Should the confidence intervals for the smooth/linear fit be
shown?
mod.line
If TRUE
three lines are added to the
scatter plot to help inform model evaluation. The 1:1 line is
solid and the 1:0.5 and 1:2 lines are dashed. Together these lines
help show how close a group of points are to a 1:1 relationship
and also
cols
Colours to be used for plotting. Options include
default, increment, heat, jet
and RColorBrewer
colours --- see the openair
openColours
function
plot.type
lattice
plot type. Can be p
(points --- default), l (lines) or b (lines and
points).
key
Should a key be drawn? The default is TRUE
.
key.title
The title of the key (if used).
key.columns
Number of columns to be used in the key. With many
pollutants a single column can make to key too wide. The user can thus
choose to use several columns by setting columns
to be less than
the number of pollutants.
key.position
Location where the scale key is to plotted. Allowed
arguments currently include top, right, bottom
and left.
strip
Should a strip be drawn? The default is TRUE
.
log.x
Should the x-axis appear on a log scale? The default is
FALSE
. If TRUE
a well-formatted log10 scale is used. This
can be useful for checking linearity once logged.
log.y
Should the y-axis appear on a log scale? The default is
FALSE
. If TRUE
a well-formatted log10 scale is used. This
can be useful for checking linearity once logged.
x.inc
The x-interval to be used for binning data when method =
"level"
.
y.inc
The y-interval to be used for binning data when method =
"level"
.
limits
For method = "level"
the function does its
best to choose sensible limits automatically. However, there are
circumstances when the user will wish to set different ones. The
limits are set in the form c(lower, upper)
, so
y.relation
This determines how the y-axis scale is
plotted. same ensures all panels use the same scale and
free will use panel-specfic scales. The latter is a
useful setting when plotting data with very different values.
x.relation
This determines how the x-axis scale is plotted. same
ensures all panels use the same scale and free will use panel-specfic
scales. The latter is a useful setting when plotting data with very
different values.
ref.x
See ref.y
for details.
ref.y
A list with details of the horizontal lines to be
added representing reference line(s). For example, ref.y =
list(h = 50, lty = 5)
will add a dashed horizontal line at
50. Several lines can be plotted e.g. ref.y = list(h = c(50,
100
k
Smoothing parameter supplied to gam
for fitting a smooth
surface when method = "level"
.
dist
When plotting smooth surfaces (method = "level"
and smooth = TRUE
, dist
controls how far from the
original data the predictions should be made. See
exclude.too.far
from the mgcv
package.
map
Should a base map be drawn? This option is under development.
auto.text
Either TRUE
(default) or FALSE
. If
TRUE
titles and axis labels will automatically try and format
pollutant names and units properly e.g. by subscripting the 2 in NO2.
...
Other graphical parameters are passed onto
cutData
and an appropriate lattice
plot function
(xyplot
, levelplot
or hexbinplot
depending on
method
). For example, scatterP