[Xts-commits] r665 - in pkg/xtsExtra: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 3 04:42:55 CEST 2012


Author: weylandt
Date: 2012-07-03 04:42:55 +0200 (Tue, 03 Jul 2012)
New Revision: 665

Modified:
   pkg/xtsExtra/R/plot.R
   pkg/xtsExtra/man/plot.xts.Rd
Log:
Added provisional support for highlighted blocks in plot.xts

Modified: pkg/xtsExtra/R/plot.R
===================================================================
--- pkg/xtsExtra/R/plot.R	2012-07-03 01:08:34 UTC (rev 664)
+++ pkg/xtsExtra/R/plot.R	2012-07-03 02:42:55 UTC (rev 665)
@@ -53,7 +53,7 @@
                        major.format=TRUE, bar.col.up = 'white',
                        bar.col.dn ='black', candle.col='black',
                        xy.labels = FALSE, xy.lines = NULL,
-                       events, 
+                       events, blocks,
                        ...) {
   
   # Restore old par() options from what I change in here
@@ -157,6 +157,14 @@
         }
       }
       
+      if(!missing(blocks)){
+        for(j in seq_along(blocks)){
+          do_add.shading(start.time = do.call(paste0("as.",indexClass(x))[1], list(get.elm.recycle(blocks[["start.time"]], j))),
+                         end.time   = do.call(paste0("as.",indexClass(x))[1], list(get.elm.recycle(blocks[["end.time"]], j))),
+                         col = if(!is.null(blocks[["col"]])) get.elm.recycle(blocks[["col"]],j) else "lightblue1", 
+                         y = range(ylim))
+        }
+      }
       col.panel  <- get.elm.from.dots("col", dots, screens, i)
       pch.panel  <- get.elm.from.dots("pch", dots, screens, i)
       cex.panel  <- get.elm.from.dots("cex", dots, screens, i)
@@ -337,7 +345,9 @@
   }
 }
 
-do_add.shading <- function(){}
+do_add.shading <- function(start.time, end.time, y, col = "lightblue1"){
+  rect(as.double(start.time), 0.5*y[1], as.double(end.time), 1.5*y[2], col = col, border = NA)
+}
 
 do_add.event <- function(time, label, y, col = "red", lty = 2){
   abline(v = time, col = col, lty = lty)

Modified: pkg/xtsExtra/man/plot.xts.Rd
===================================================================
--- pkg/xtsExtra/man/plot.xts.Rd	2012-07-03 01:08:34 UTC (rev 664)
+++ pkg/xtsExtra/man/plot.xts.Rd	2012-07-03 02:42:55 UTC (rev 665)
@@ -12,7 +12,7 @@
             major.format=TRUE, bar.col.up = 'white',
             bar.col.dn ='black', candle.col='black',
             xy.labels = FALSE, xy.lines = NULL, 
-            events, ...)
+            events, blocks ...)
 }
 \arguments{
   \item{x}{an \code{xts} object}
@@ -31,6 +31,8 @@
   \item{xy.lines}{connect points in scatterplot?}
   \item{events}{A list with mandatory elements \code{time} and \code{label} and optional 
   elements \code{col} and \code{lty} giving the events to be highlighted. See examples.}
+  \item{blocks}{A list with mandatory elements \code{start.time} and \code{end.time} and 
+  optional element \code{col} giving time-blocks to be highlighted. See examples.}
   \item{\dots}{additional graphical arguments}
 }
 \details{



More information about the Xts-commits mailing list