Learn R Programming

hydroTSM (version 0.2-0)

drawxaxis: Customized 'x' axis

Description

For a nicer ts plot, this function draws a customized x axis, with daily, monthly, or annual time marks and labels.

Usage

drawxaxis(x, tick.tstep = "months", lab.tstep = "years", cex.axis=1, ...)

Arguments

x
time series that will be plotted using the X axis that will be draw class(x) must be ts or zoo
tick.tstep
Character indicating the time step that have to be used for putting the ticks on the time axis. Valid values are: days, months, years.
lab.tstep
Character indicating the time step that have to be used for putting the labels on the time axis. Valid values are: days, months, years.
cex.axis
magnification of axis annotation relative to cex (See par).
...
further arguments passed to the Axis function or from other methods.

Examples

Run this code
## Loading the SanMartino precipitation data
data(SanMartinoPPts)
x <- window(SanMartinoPPts, end=as.Date("1935-12-31"))

## Plotting the daily ts without an 'x' axis
plot(x, xaxt = "n", col="blue" )

## Draws monthly ticks in the 'x' axis, but labels only in years
drawxaxis(x, tick.tstep="months", lab.tstep="years", xlab="Time")

Run the code above in your browser using DataLab