Learn R Programming

FREddyPro (version 1.0)

plotDiurnal: Plot average diurnal patterns

Description

Calculating and plotting the diurnal pattern of any variable with the option to use mean or both mean and median. There is also an option to plot quantiles.

Usage

plotDiurnal(data, xVar, hourX, dataY = NULL, yVar = NULL, hourY = NULL, median = FALSE, quantiles = FALSE, probs = c(0.05, 0.95), stdev = FALSE, sterr = FALSE, legend = FALSE, legendSide = NULL, legendText = NULL, type = "l", lty = c(1, 4), col = c(1, 2), cex.legend = 1, horiz.legend = TRUE, ylab = "Mean", xlab = "Hour", ...)

Arguments

data
The data frame to plot
xVar
The variable to plot
hourX
The hour variable associated with the X variable
dataY
A second data frame to plot (optional)
yVar
A second optional variable to plot.
hourY
The hour variable associated with the Y variable, also optional.
median
Logical. If TRUE the median is also plotted with the mean.
quantiles
Logical. If TRUE the quantiles will be plotted as a colour band
probs
An array of the quantiles to use. The default is 0.05 and 0.95 (5th and 95th).
stdev
Logical. If True the standard deviation is plotted as a colour band
sterr
Logical. If True the standard error is plotted as a colour band
legend
Logical. If TRUE a legend will be plotted.
legendSide
The side of the plot to place the legend.
legendText
The text to use for legend.
type
The type of plot. The default is a line plot.
lty
The type of line when a line plot is used.
col
The colour to use for the lines or points. It can be a single values or an array.
cex.legend
The size of the legend labels.
horiz.legend
A logical parameter. If TRUE the legend is will be placed horizontally.
ylab
The y-axis label.
xlab
The x-axis label.
...
Further graphical options.

Details

The function first aggregates the given variable to half hourly and plots by default the mean. The median can also be plotted with the mean. There is an optional graphical output for quantiles. By default is the 5th and 95th but other quantiles can be used. There are two separate hourly inputs to the functions to allow plotting variables from different data frames.

Examples

Run this code
## Load the data
data(fluxes)

## Clean and despike the fluxes
fluxes=cleanFluxes(fluxes,sdCor=TRUE,sdTimes=3,distCor=TRUE,timesList=3,
thresholdList=list(H=c(-100,1000),LE=c(-100,1000)))	

## Create timestamp
fluxes=createTimestamp(fluxes)

## Plot the diurnal patterns
plotDiurnal(fluxes, xVar="H", hourX="hour",yVar="LE",hourY="hour",
median=TRUE,stdev=TRUE,ylim=c(-100,400),lty=c(1,2,3,4),col=c(1,2,3,4),
legend=TRUE,legendSide='topleft',legendText=c("sensible heat","latent heat"),
lwd=2,ylab="Heat (W/m"^2~")",main="Harwood forest",cex.legend=0.9,
horiz.legend=FALSE)

abline(h=0,lty=2)

Run the code above in your browser using DataLab