Learn R Programming

berryFunctions (version 1.22.5)

yearPlot: annual plot

Description

Visualize seasonality of time series

Usage

yearPlot(
  dates,
  values,
  data,
  ylim = NULL,
  shift = 0,
  janline = TRUE,
  add = FALSE,
  months = substr(month.abb, 1, 1),
  xlab = "",
  ylab = "",
  zlab = "",
  ...
)

Value

invisible list with coordinates

Arguments

dates

Dates, in any format coerced by as.Date.

values

Values to be mapped in color with colPoints

data

Optional: data.frame from which to use dates and values.

ylim

(reverse) date range in numerical years. DEFAULT: NULL (computed from dates internally)

shift

Number of days to move the year-break to. E.g. shift=61 for German hydrological year (Nov to Oct). DEFAULT: 0

janline

Logical: Should vertical line be plotted at January 1st if shift!=0? DEFAULT: TRUE

add

Logical. Add to existing plot? DEFAULT: FALSE

months

Labels for the months. DEFAULT: J,F,M,A,M,J,J,A,S,O,N,D

xlab, ylab, zlab

Axis and legend labels. DEFAULT: ""

...

Further arguments passed to colPoints like legend, pch, main, xaxs, ...

Author

Berry Boessenkool, berry-b@gmx.de, Sept 2019

See Also

seasonality, colPoints,

Examples

Run this code
qfile <- system.file("extdata/discharge39072.csv", package="berryFunctions")
Q <- read.table(qfile, skip=19, header=TRUE, sep=",", fill=TRUE)[,1:2]
Q$data <- as.Date(Q$data)
yearPlot(data, last, data=Q)
yearPlot(as.Date(c("2011-06-07","2009-03-25")), 1:2, add=TRUE, pch=3, col=1, legend=FALSE)
yearPlot(data, last, data=Q, shift=61)
yearPlot(data, last, data=Q, ylim=c(2015,2001))

Run the code above in your browser using DataLab