rvn_xts_plot: Create plot from xts data

View source: R/rvn_xts_plot.R

rvn_xts_plotR Documentation

Create plot from xts data

Description

Generic function for plotting data from an xts format using the ggplot2 function.

Usage

rvn_xts_plot(
  x = NULL,
  prd = NULL,
  winter_shading = FALSE,
  wsdates = c(12, 1, 3, 31)
)

Arguments

x

time series object (xts) of data to plot

prd

period to use in plotting

winter_shading

optionally adds shading for winter months (default FALSE)

wsdates

integer vector of winter shading period dates (see details)

Details

Creates a plot using the supplied time series in xts format. The xts object is converted to a tibble using the rvn_fortify_xts function, and all columns are plotted by their respective names.

The winter_shading argument will add a transparent grey shading for the specified period by wsdates in each year that is plotted. Note that by changing the wsdates parameter values, the shading can be applied to any time of year.

wsdates is formatted as c(winter start month, winter start day, winter end month, winter end day). By default, wsdates is set to generate shading for December 1st to March 31st.

Note that a plot title is purposely omitted in order to allow the automatic generation of plot titles.

Value

p1

returns ggplot plot object

See Also

rvn_hyd_plot to create a hydrograph plot

rvn_hyd_extract to extract time series from Raven objects

Examples


# load sample hydrograph data, two years worth of sim/obs
ff <- system.file("extdata","run1_Hydrographs.csv", package="RavenR")
run1 <- rvn_hyd_read(ff)

# create a hydrograph with the generic xts plotting function
rvn_xts_plot(run1$hyd[,2:5])

# add shading for the month of August
rvn_xts_plot(run1$hyd[,2:5], winter_shading=TRUE, wsdates=c(8,1,8,31))


rchlumsk/RavenR documentation built on April 19, 2024, 5:15 a.m.