calendarPlot(mydata, pollutant = "nox", year = 2003, month = 1:12,
type = "default", annotate = "date", statistic = "mean",
cols = "heat", limits = c(0, 100), lim = NULL, col.lim = c("grey30",
"black"), font.lim = c(1, 2), cex.lim = c(0.6, 1), digits = 0,
data.thresh = 0, labels = NA, breaks = NA, main = paste(pollutant,
"in", year), key.header = "", key.footer = "", key.position = "right",
key = TRUE, auto.text = TRUE, ...)
date
and at
least one other numeric variable. The date should be in either
Date
format or class POSIXct
.pollutant = "nox".
year = 2003
.month
option where month
is a numeric 1:12 e.g. month = c(1, 12)
to only plot
JatimeAverage
.RColorBrewer
colours --- see the openair
openColours
function forlim
. It is used when annotate =
"value"
. See next few options for control over the labels used.lim
and
the second sets the colour of the text above lim
.lim
and the
second sets the font of the text above lim
. Note that font
= 1 is normal text and font = 2 is bold text.lim
and
the second sets the size of the text above lim
.annotate = "value"
.timeAverage
. For example, data.thresh = 75
means
that at least 75% of the data must be available in a day for the
value to be calculate, else the data is removed.labels = c("good", "bad", "very
bad")
. breaks
must also be supplied if labels are given.breaks = c(0, 50, 100, 1000)
. In
this case bre
calendarPlot(mydata, key.header = "header",
key.footer = "footer")
adds addition text above and below the scale key.
These arguments are passed to drawOpenKey
viakey.header
."top"
, "right"
, "bottom"
and "left"
.drawOpenKey
. See
drawOpenKey
for further details.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.lattice
function lattice:levelplot
, with common axis and title labelling
options (such as xlab
, ylab
, main
) being passed to
via quickText
calendarPlot
also
returns an object of class ``openair''. The object includes three main
components: call
, the command used to generate the plot;
data
, the data frame of summarised information used to make the
plot; and plot
, the plot itself. If retained, e.g. using
output <- calendarPlot(mydata, "nox")
, this output can be used to
recover the data, reproduce or rework the original plot or undertake
further analysis.An openair output can be manipulated using a number of generic operations,
including print
, plot
and summary
.
calendarPlot
will plot one year of data in a conventional
calendar format i.e. by month and day of the week. The main
purpose of this function is to make it easy to visualise data in a
familiar way. Daily statistics are calculated using
timeAverage
, which by default will calculate the
daily mean concentration.If wind direction is available it is then possible to plot the wind
direction vector on each day. This is very useful for getting a feel for
the meteorological conditions that affect pollutant concentrations. Note
that if hourly or higher time resolution are supplied, then
calendarPlot
will calculate daily averages using
timeAverage
, which ensures that wind directions are
vector-averaged.
If wind speed is also available, then setting the option annotate =
"ws"
will plot the wind vectors whose length is scaled to the wind speed.
Thus information on the daily mean wind speed and direction are available.
It is also possible to plot categorical scales. This is useful
where, for example, an air quality index defines concentrations as
bands e.g. labels
and corresponding breaks
.
Note that is is possible to pre-calculate concentrations in some
way before passing the data to calendarPlot
. For example
rollingMean
could be used to calculate rolling
8-hour mean concentrations. The data can then be passed to
calendarPlot
and statistic = "max"
chosen, which
will plot maximum daily 8-hour mean concentrations.
timePlot
, timeVariation
# load example data from package
data(mydata)
# basic plot
calendarPlot(mydata, pollutant = "o3", year = 2003)
# show wind vectors
calendarPlot(mydata, pollutant = "o3", year = 2003, annotate = "wd")
# show wind vectors scaled by wind speed and different colours
calendarPlot(mydata, pollutant = "o3", year = 2003, annotate = "ws",
cols = "heat")
# show only specific months with selectByDate
calendarPlot(selectByDate(mydata, month = c(3,6,10), year = 2003),
pollutant = "o3", year = 2003, annotate = "ws", cols = "heat")
# categorical scale example
calendarPlot(mydata, pollutant = "no2", breaks = c(0, 50, 100, 150, 1000),
labels = c("Very low", "Low", "High", "Very High"),
cols = c("lightblue", "green", "yellow", "red"), statistic = "max")
Run the code above in your browser using DataLab