[Xts-commits] r689 - pkg/xtsExtra/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jul 20 22:59:08 CEST 2012


Author: weylandt
Date: 2012-07-20 22:59:08 +0200 (Fri, 20 Jul 2012)
New Revision: 689

Modified:
   pkg/xtsExtra/R/barplot.R
Log:
Barplot axis alignment patch from K Russell

Modified: pkg/xtsExtra/R/barplot.R
===================================================================
--- pkg/xtsExtra/R/barplot.R	2012-07-19 20:16:58 UTC (rev 688)
+++ pkg/xtsExtra/R/barplot.R	2012-07-20 20:59:08 UTC (rev 689)
@@ -56,13 +56,21 @@
   
   ep1 <- ep <- axTicksByTime(x, major.ticks, format.labels = major.format)
   
-  posn = barplot(t(x), plot=FALSE, space=space)
-  if(!stacked) posn <- posn*nc
+  ### Patch from Kent Russell on Jul 20 
+  #######################################
   
-  # Vectorize this?
-  for(i in 1:length(ep)) 
-    ep1[i] = posn[ep[i]]
+  if(stacked){
+    posn = barplot(t(x), plot = FALSE, space = space)
+    for(i in seq_along(ep)) ep1[i] = posn[ep[i]] # Vectorize?
+  } else {
+    posn = barplot(t(x), plot = FALSE, beside = TRUE) 
+    # FIXME support space: space = c(0, space) ? 
+    for(i in seq_along(ep)) ep1[i] = posn[2,ep[i]] # Vectorize?
+  }
   
+  #######################################
+  
+  
   # Handle strange double-plotting from axTicksByTime
   ep1 <- ep1[!duplicated(ep1)]
   
@@ -112,7 +120,7 @@
   
   if (xaxis) {
     if(minor.ticks)
-      axis(1, at=posn, labels=FALSE, col='#BBBBBB')
+      axis(1, at = if(stacked) posn else posn[2,], labels = FALSE, col = '#BBBBBB')
     
     if(is.null(xaxis.labels))
       xaxis.labels = names(ep1)



More information about the Xts-commits mailing list