Learn R Programming

openair (version 0.3-13)

calendarPlot: Plot time series values in convential calendar format

Description

This function will plot one year of 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.

Usage

calendarPlot(mydata,
    pollutant = "nox", year = 2003, type = "default", 
    annotate = "date", statistic = "mean", 
    cols = "heat", limits = c(0, 100),
    main = quickText((paste(pollutant, "in", year))),
    key.header = "", key.footer = "", 
    key.position = "right", key = NULL,
    auto.text = TRUE, ...)

Arguments

mydata
A data frame minimally containing date and at least one other numeric variable and a year. The date should be in either Date format or class POSIXct.
pollutant
Mandatory. A pollutant name corresponding to a variable in a data frame should be supplied e.g. pollutant = "nox".
year
Year to plot e.g. year = 2003.
type
Not yet implemented.
annotate
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.
statistic
Not currently implemented - only mean is currently calculated.
cols
Colours to be used for plotting. Options include "default", "increment", "heat", "jet" and user defined. For user defined the user can supply a list of colour names recognised by R (type colours() to see the full list). An exam
limits
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 maximimum range of the data for all plots of
main
The plot title; default is pollutant and year.
key.header, key.footer
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 drawOpenKe
key.position
Location where the scale key is to plotted. Allowed arguments currently include "top", "right", "bottom" and "left".
key
Fine control of the scale key via drawOpenKey. See drawOpenKey for further details.
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.

Warning

This function is under development.

Details

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. Currently the mean value of a variable is plotted using a colour scale. Further statistics will be added in due course. If wind direction are 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.

See Also

timePlot, timeVariation

Examples

Run this code
# 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")

Run the code above in your browser using DataLab