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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jul 12 02:46:02 CEST 2012


Author: weylandt
Date: 2012-07-12 02:46:02 +0200 (Thu, 12 Jul 2012)
New Revision: 677

Modified:
   pkg/xtsExtra/R/plot.R
   pkg/xtsExtra/man/plot.xts.Rd
Log:
Added nc and nr for plot.zoo compatability

Modified: pkg/xtsExtra/R/plot.R
===================================================================
--- pkg/xtsExtra/R/plot.R	2012-07-11 23:17:41 UTC (rev 676)
+++ pkg/xtsExtra/R/plot.R	2012-07-12 00:46:02 UTC (rev 677)
@@ -23,15 +23,12 @@
 #    I think layout is working, but need to turn off x/y labels smartly when things are adjacent
 #    Handle not adjacent cases
 #    
-#    DO LAYOUT WITHOUT USING LAYOUT -- NEED TO BE ABLE TO MOVE BETWEEN PLOTS WHEN ADDING LINES?
-#    GET LAYOUT TO SUPPORT ADJACENT COLUMNS
+#    DO LAYOUT WITHOUT USING LAYOUT? -- NEED TO BE ABLE TO MOVE BETWEEN PLOTS WHEN ADDING LINES?
 #    legend.loc
 #    COLOR GRADIENT FOR SCATTERPLOT CASE
-#    Combine OHLC and multi-panel (i.e., if passed cbind(SPY, AGG)) 
-#    Smarter OHLC candle width? I like bar width
-#    Change default OHLC colors
-#    Support up/down OHLC bar colors or is it better to use quantmod at this point?
-#    ylab.loc = c("left", "right", "out","in","flip","above") -- above kills panel alignment automatically
+#    ylab.loc = "above" -- above kills panel alignment automatically
+#    ylab.loc = "none"  -- needs to do ylim better
+#    ylim handling?
 #    Refactor plotting functionality into some non-exported bits
 #    It stopped showing ylab when I did the axis hardcoding -- should be fixed with margins
 #    x <- as.xts(sample_matrix); plot(cbind(x, x[,1]), layout = matrix(1:6, ncol = 2)) -- is this a bug?: JMU
@@ -53,7 +50,7 @@
                        major.format=TRUE, bar.col.up = 'white',
                        bar.col.dn ='red', candle.col='black',
                        xy.labels = FALSE, xy.lines = NULL,
-                       events, blocks,
+                       events, blocks, nc, nr,
                        ...) {
   
   # Restore old par() options from what I change in here
@@ -118,7 +115,7 @@
   } else {  
     # Else need to do layout plots
     screens <- do_layout(x, screens = screens, layout.screens = layout.screens, 
-                         ylab.loc = ylab.loc)
+                         ylab.loc = ylab.loc, nc = nc, nr = nr)
     
     have_x_axis <- screens[["have_x_axis"]]
     have_y_axis <- screens[["have_y_axis"]]
@@ -201,13 +198,21 @@
   return(invisible(xy.xts))
 }
 
-do_layout <- function(x, screens, layout.screens, ylab.loc){
+do_layout <- function(x, screens, layout.screens, ylab.loc, nc, nr){
   # By default one screen per panel
   screens <- factor(if(identical(screens,"auto")) 1:NCOL(x) else 
     rep(screens, length.out = NCOL(x)))
   
+  
+  
   if(identical(layout.screens, "auto")){
     layout.screens <- seq_along(levels(screens))
+    if(!missing(nc) && !missing(nr)) 
+      layout.screens <- matrix(layout.screens, ncol = nc, nrow = nrow)
+    if(missing(nc) && !missing(nr))
+      layout.screens <- matrix(layout.screens, nrow = nr)
+    if(!missing(nc) && missing(nr))
+      layout.screens <- matrix(layout.screens, ncol = nc)
   }
   
   layout.screens <- as.matrix(layout.screens)

Modified: pkg/xtsExtra/man/plot.xts.Rd
===================================================================
--- pkg/xtsExtra/man/plot.xts.Rd	2012-07-11 23:17:41 UTC (rev 676)
+++ pkg/xtsExtra/man/plot.xts.Rd	2012-07-12 00:46:02 UTC (rev 677)
@@ -12,7 +12,7 @@
             major.format=TRUE, bar.col.up = 'white',
             bar.col.dn ='red', candle.col='black',
             xy.labels = FALSE, xy.lines = NULL, 
-            events, blocks, ...)
+            events, blocks, nc, nr, ...)
 }
 \arguments{
   \item{x}{an \code{xts} object}
@@ -33,6 +33,8 @@
   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{nc}{Number of columns to be used if \code{layout} is set to \code{'auto'}.}
+  \item{nr}{Number of rows to be used if \code{layout} is set to \code{'auto'}.}
   \item{\dots}{additional graphical arguments}
 }
 \details{



More information about the Xts-commits mailing list