Skip to contents

This function will plot data by month laid out in a conventional calendar format. The main purpose is to help rapidly visualise potentially complex data in a familiar way. Users can also choose to show daily mean wind vectors if wind speed and direction are available.


  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"),
  col.arrow = "black",
  font.lim = c(1, 2),
  cex.lim = c(0.6, 1),
  digits = 0,
  data.thresh = 0,
  labels = NA,
  breaks = NA,
  w.shift = 0,
  w.abbr.len = 1,
  remove.empty = TRUE,
  main = NULL,
  key.header = "",
  key.footer = "",
  key.position = "right",
  key = TRUE,
  auto.text = TRUE,
  plot = TRUE,



A data frame minimally containing date and at least one other numeric variable. The date should be in either Date format or class POSIXct.


Mandatory. A pollutant name corresponding to a variable in a data frame should be supplied e.g. pollutant = "nox".


Year to plot e.g. year = 2003. If not supplied all data potentially spanning several years will be plotted.


If only certain month are required. By default the function will plot an entire year even if months are missing. To only plot certain months use the month option where month is a numeric 1:12 e.g. month = c(1, 12) to only plot January and December.


Not yet implemented.


This option controls what appears on each day of the calendar. Can be: "date" --- shows day of the month; "wd" --- shows vector-averaged wind direction, or "ws" --- shows vector-averaged wind direction scaled by wind speed. Finally it can be “value” which shows the daily mean value.


Statistic passed to timeAverage(). Note that if statistic = "max" and annotate is "ws" or "wd", the hour corresponding to the maximum concentration of polluant is used to provide the associated ws or wd and not the maximum daily ws or wd.


Colours to be used for plotting. See openColours() for more details.


Use this option to manually set the colour scale limits. This is useful in the case when there is a need for two or more plots and a consistent scale is needed on each. Set the limits to cover the maximum range of the data for all plots of interest. For example, if one plot had data covering 0--60 and another 0--100, then set limits = c(0, 100). Note that data will be ignored if outside the limits range.


A threshold value to help differentiate values above and below lim. It is used when annotate = "value". See next few options for control over the labels used.


For the annotation of concentration labels on each day. The first sets the colour of the text below lim and the second sets the colour of the text above lim.


The colour of the annotated wind direction / wind speed arrows.


For the annotation of concentration labels on each day. The first sets the font of the text below 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.


For the annotation of concentration labels on each day. The first sets the size of the text below lim and the second sets the size of the text above lim.


The number of digits used to display concentration values when annotate = "value".


Data capture threshold passed to timeAverage(). For example, data.thresh = 75 means that at least 75\ available in a day for the value to be calculate, else the data is removed.


If a categorical scale is defined using breaks, then labels can be used to override the default category labels, e.g., labels = c("good", "bad", "very bad"). Note there is one less label than break.


If a categorical scale is required then these breaks will be used. For example, breaks = c(0, 50, 100, 1000). In this case “good” corresponds to values between 0 and 50 and so on. Users should set the maximum value of breaks to exceed the maximum data value to ensure it is within the maximum final range e.g. 100--1000 in this case.


Controls the order of the days of the week. By default the plot shows Saturday first (w.shift = 0). To change this so that it starts on a Monday for example, set w.shift = 2, and so on.


The default (1) abbreviates the days of the week to a single letter (e.g., in English, S/S/M/T/W/T/F). w.abbr.len defines the number of letters to abbreviate until. For example, w.abbr.len = 3 will abbreviate "Monday" to "Mon".


Should months with no data present be removed? Default is TRUE.


The plot title; default is pollutant and year.


Adds additional text/labels to the scale key. For example, passing calendarPlot(mydata, key.header = "header", key.footer = "footer") adds addition text above and below the scale key. These arguments are passed to drawOpenKey() via quickText(), applying the auto.text argument, to handle formatting.


see key.header.


Location where the scale key is to plotted. Allowed arguments currently include "top", "right", "bottom" and "left".


Fine control of the scale key via drawOpenKey(). See drawOpenKey() for further details.


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.


Should a plot be produced? FALSE can be useful when analysing data to extract calendar plot components and plotting them in other ways.


Other graphical parameters are passed onto the lattice function lattice::levelplot(), with common axis and title labelling options (such as xlab, ylab, main) being passed to via quickText() to handle routine formatting.


an openair object


calendarPlot() will plot data in a conventional calendar format, i.e., by month and day of the week. 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., "good", "poor". In these cases users must supply 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.

See also

Other time series and trend functions: TheilSen(), runRegression(), smoothTrend(), timePlot(), timeProp(), timeVariation(), trendLevel()


David Carslaw


# basic plot
calendarPlot(mydata, pollutant = "o3", year = 2003)

# show wind vectors
calendarPlot(mydata, pollutant = "o3", year = 2003, annotate = "wd")

if (FALSE) {
# show wind vectors scaled by wind speed and different colours
  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
  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"

# UK daily air quality index
pm10.breaks <- c(0, 17, 34, 50, 59, 67, 75, 84, 92, 100, 1000)
calendarPlot(mydata, "pm10",
  year = 1999, breaks = pm10.breaks,
  labels = c(1:10), cols = "daqi", statistic = "mean", key.header = "DAQI"