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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 24 19:31:08 CEST 2012


Author: weylandt
Date: 2012-07-24 19:31:08 +0200 (Tue, 24 Jul 2012)
New Revision: 693

Modified:
   pkg/xtsExtra/R/plot.R
Log:
More work on margins for plot.xts -- now dynamically adds a little extra height for plots with x axis

Modified: pkg/xtsExtra/R/plot.R
===================================================================
--- pkg/xtsExtra/R/plot.R	2012-07-24 17:01:01 UTC (rev 692)
+++ pkg/xtsExtra/R/plot.R	2012-07-24 17:31:08 UTC (rev 693)
@@ -204,11 +204,6 @@
   
   layout.screens <- as.matrix(layout.screens)
   
-  # Would like to use do.call and as.list so pro-users can pass widths and heights
-  # to layout -- currently undocumented behavior
-  # do.call("layout", as.list(layout.screens)) 
-  if(length(layout.screens) > 1L) layout(layout.screens)
-  
   have_x_axis <- logical(length(levels(screens)))
   for(i in seq_len(NROW(layout.screens))){
     if(i == NROW(layout.screens)){
@@ -263,6 +258,7 @@
   # Moving internal margin code to the panel-wise setup, leaving oma (outer) margin here
   if(length(levels(screens)) > 1L) par(oma = c(1,1,4,1))
   if(yax.loc == "none") par(oma = c(1,4,4,3))
+  if(length(levels(screens)) == 1L && yax.loc != "none") par(oma = c(1,1,4,1))
   
   if(identical(ylim,'fixed')){
     ylim <- list(range(x))
@@ -279,6 +275,16 @@
     ylim <- lapply(1:NROW(ylim), function(x) ylim[x,1:2])
   }
   
+  # Would like to use do.call and as.list so pro-users can pass widths and heights
+  # to layout -- currently undocumented behavior
+  # do.call("layout", as.list(layout.screens)) 
+  # Currently I add a little bit extra height to those screens with x-axes
+  if(length(layout.screens) > 1L) 
+    layout(layout.screens, heights = 1 + 0.05*NROW(unique(layout.screens)) * 
+      sapply(1:NROW(layout.screens), # More dirty hacking.... still not perfect
+                            function(j) any(have_x_axis[layout.screens[j,]])))
+  
+  
   return(list(screens = screens, have_x_axis = have_x_axis, 
               have_y_axis = have_y_axis, ylab.axis = ylab.axis, ylim = ylim))
 }



More information about the Xts-commits mailing list