plotBand: Plot a band (e.g. confidence band) in a chart

View source: R/plotBand.R

plotBandR Documentation

Plot a band (e.g. confidence band) in a chart

Description

This function facilitates plotting coloured 95 intuitive syntax than polygon. It is often used together with addAlpha for drawing nice figures.

Usage

plotBand(x, y.lo, y.hi, col)

Arguments

x

A vector of x values

y.lo

A vector of y values, the lower limit of the confidence band

y.hi

A vector of y values, the upper limit of the confidence band

col

What colour to draw the band?

Details

This function calculates the week number according to ISO 8601. Note that dates near the start or end of a given year may belong to the previous or next year respectively, thus the year needs to be calculated too.

Value

None

Examples

with(cars, plot(speed, dist))
m <- lm(dist~speed, data=cars)
p <- data.frame(speed=seq(min(cars$speed), max(cars$speed), by=0.1))
p <- cbind(p, predict(m, p, interval="confidence"))
with(cars, plot(speed, dist, type="n"))
plotBand(p$speed, p$lwr, p$upr, col="skyblue")
abline(m, lwd=2)
with(cars, points(speed, dist, type="p", pch=19))


thlytras/Rivets documentation built on April 16, 2024, 5:43 a.m.