Learn R Programming

hydroTSM (version 0.3-5)

hydroplot: Hydrological time series plotting and extraction.

Description

hydroplot: When x is a zoo object it plots (a maximum of) 9 graphs (lines plot, boxplots and/or histograms) of the daily, monthly, annual and/or seasonal time series. sname2plot: When x is a data frame whose columns contain the time series of several gauging stations, it takes the name of one gauging station and plots the graphs described above.

Usage

hydroplot(x, FUN, na.rm=TRUE, ptype="ts+boxplot+hist", pfreq="dma",                      
          var.type, var.unit="units", main=NULL, xlab="Time", ylab,
          win.len1=0, win.len2=0, tick.tstep="auto", lab.tstep="auto", 
          lab.fmt=NULL, cex=0.3, cex.main=1.3, cex.lab=1.3, cex.axis=1.3, 
          col=c("blue", "lightblue", "lightblue"), 
          from, to, date.fmt= "%Y-%m-%d", stype="default", h=NULL, ...)

sname2plot(x, sname, FUN, na.rm=TRUE, ptype="ts+boxplot+hist", pfreq="dma", var.type, var.unit="units",main=NULL, xlab="Time", ylab=NULL, win.len1=0, win.len2=0, tick.tstep="auto", lab.tstep="auto", lab.fmt=NULL, cex=0.3, cex.main=1.3, cex.lab=1.3, cex.axis=1.3, col=c("blue", "lightblue", "lightblue"), dates, date.fmt = "%Y-%m-%d", from, to, stype="default", h=NULL )

Arguments

x
zoo, xts or data.frame object, with columns storing the time series of one or more gauging stations.
sname
ONLY required when x is a data frame. Character representing the name of a station, which have to correspond to one column name in x
FUN
ONLY required when var.type is missing AND pfreq != "o". Function that have to be applied for transforming from daily to monthly or annual time step (e.g., For precipitation FUN=sum and for temperature and flow ts,
na.rm
Logical. Should missing values be removed before the computations?
ptype
Character indicating the type of plot that will be plotted. Valid values are: -) ts => only time series -) ts+boxplot => only time series + boxplot -) ts+hist => only ti
pfreq
Character indicating how many plots are desired by the user. Valid values are: -) dma : Daily, Monthly and Annual values are plotted -) dm : Daily and Monthly values are plotted -) ma : Monthly and Annual
var.type
ONLY required when FUN is missing. character representing the type of variable being plotted. Used for determining the function used for computing the monthly and annual values when FUN is missing. Valid values are: -) Pre
var.unit
Character representing the measurement unit of the variable being plotted. ONLY used for labelling the axes (e.g., "mm" for precipitation, "C" for temperature, and "m3/s" for flow.)
main
Character representing the main title of the plot. If the user do not provide a title, this is created automatically as: main= paste(var.type, "at", sname, sep=""),
xlab
A title for the x axis. See plot.
ylab
A title for the y axis. See plot.
win.len1
number of days for being used in the computation of the first moving average. A value equal to zero indicates that this moving average is not going to be computed.
win.len2
number of days for being used in the computation of the second moving average. A value equal to zero indicates that this moving average is not going to be computed.
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
lab.fmt
Character indicating with the format to be used for the label of the axis. See format in as.Date. If not specified, it will try "%Y-%m-%d" when lab.tstep=="days",
cex
A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default. (See par).
cex.main
The magnification to be used for main titles relative to the current setting of cex (See par).
cex.lab
The magnification to be used for x and y labels relative to the current setting of cex (See par).
cex.axis
The magnification to be used for axis annotation relative to the current setting of cex (See par).
col
A character vector with 3 elements, representing the colors to be used for plotting the lines of the ts, the boxplots, and the histograms, respectively. When pfreq="o", only one character element is needed. See
dates
ONLY required when x is a data frame. It is a numeric, factor or Date object indicating how to obtain the dates corresponding to the sname station. If dates is a number, it indicates the index of the column in
date.fmt
Character indicating the format in which the dates are stored in dates, from and to. See format in as.Date. ONLY required when class(dates)=="factor"
from
OPTIONAL, used for extracting a subset of values. Character indicating the starting date for the values to be extracted. It must be provided in the format specified by date.fmt.
to
OPTIONAL, used for extracting a subset of values. Character indicating the ending date for the values to be extracted. It must be provided in the format specified by date.fmt.
stype
OPTIONAL, only used when pfreq=seasonal. character, indicating which weather seasons will be used for computing the output. Possible values are: -) default => "winter"= Dec, Jan, Feb; "spring"= Mar, Apr, May; "sum
h
OPTIONAL, only used when pfreq=seasonal, for plotting horizontal lines in each seasonal plot. numeric, with 1 or 4 elements, with the value used for plotting an horizontal line in each seasonal plot, in the following order: winter (DJF), spr
...
further arguments passed to the plot.zoo and axis functions or from other methods.

Details

Plots of the daily/monthly/annual/seasonal values of the time series given as input. Depending on the value of pfreq, daily, monthly, annual and/or seasonal time series plots, boxplots and histograms are produced. Depending on the value of ptype, time series plots, boxplots and/or histograms are produced.

See Also

sname2ts

Examples

Run this code
#############
## Loading daily streamflows at the station Oca en Ona (Ebro River basin, Spain) ##
data(OcaEnOnaQts)

## 3 ts, 3 boxplots and 3 histograms
hydroplot(OcaEnOnaQts, FUN=mean, ylab= "Q", var.unit = "m3/s")

## only the original time series
hydroplot(OcaEnOnaQts, pfreq="o")

## only the year 1962 of the original time series
hydroplot(OcaEnOnaQts, pfreq="o", from="1962-01-01", to="1962-12-31")

## seasonal plots
hydroplot(OcaEnOnaQts, pfreq="seasonal", FUN=mean, stype="default")

#############
## Loading the monthly time series of precipitation within the Ebro River basin.
data(EbroPPtsMonthly)

## Plotting the monthly and annual values of precipitation at station "P9001", 
## stored in 'EbroPPtsMonthly'.
sname2plot(EbroPPtsMonthly, sname="P9001", var.type="Precipitation", dates=1, pfreq="ma")

## Plotting seasonal precipitation at station "P9001"
sname2plot(EbroPPtsMonthly, sname="P9001", FUN=sum, dates=1, pfreq="seasonal", stype="default")

Run the code above in your browser using DataLab