plotBand | R Documentation |
This function facilitates plotting coloured 95
intuitive syntax than polygon
. It is often used together with addAlpha
for drawing nice figures.
plotBand(x, y.lo, y.hi, col)
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? |
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.
None
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.