Skip to content

Commit

Permalink
Add addPolygon() example
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaulrich committed Jul 24, 2023
1 parent 05dd10c commit fffe583
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions man/addPolygon.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ addPolygon(x, y = NULL, main = "", on = NA, col = NULL, ...)
\item{col}{color palette to use, set by default to rational choices.}
\item{\dots}{passthru parameters to \code{\link{par}}}
}
\examples{
\dontrun{
library(xts)
data(sample_matrix)
x <- as.xts(sample_matrix)[,1]
ix <- index(x["2007-02"])
shade <- xts(matrix(rep(range(x), each = length(ix)), ncol = 2), ix)

plot(x)

# set on = -1 to draw the shaded region *behind* the main series
addPolygon(shade, on = -1, col = "lightgrey")
}
}
\references{
Based on code by Dirk Eddelbuettel from \url{http://dirk.eddelbuettel.com/blog/2011/01/16/}
}
Expand Down

0 comments on commit fffe583

Please sign in to comment.