From fffe58399ff30ecec3c0915c8f4a7667f251b894 Mon Sep 17 00:00:00 2001 From: Joshua Ulrich Date: Mon, 24 Jul 2023 12:24:22 -0500 Subject: [PATCH] Add addPolygon() example --- man/addPolygon.Rd | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/man/addPolygon.Rd b/man/addPolygon.Rd index 1a32cd1c..fe5c723d 100644 --- a/man/addPolygon.Rd +++ b/man/addPolygon.Rd @@ -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/} }