[Phylobase-commits] r521 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Aug 20 00:44:10 CEST 2009


Author: pdc
Date: 2009-08-20 00:44:10 +0200 (Thu, 20 Aug 2009)
New Revision: 521

Modified:
   pkg/R/treePlot.R
Log:
space label a bit nicer and remove some duplicate code

Modified: pkg/R/treePlot.R
===================================================================
--- pkg/R/treePlot.R	2009-08-19 22:33:57 UTC (rev 520)
+++ pkg/R/treePlot.R	2009-08-19 22:44:10 UTC (rev 521)
@@ -323,6 +323,7 @@
     nVars <- ncol(tipdata) # number of bubble columns
 
     dlabwdth <- max(stringWidth(colnames(phy at tip.data))) * 1.2
+    if(convertWidth(dlabwdth, 'cm', valueOnly=TRUE) < 2) {dlabwdth <- unit(2, 'cm')}
     phyplotlayout <- grid.layout(nrow = 2, ncol = 2, 
         heights = unit.c(unit(1, 'null'), dlabwdth), 
         widths = unit(c(1, 1), c('null', 'null'), list(NULL, NULL)))
@@ -364,12 +365,11 @@
     if(lab.right) {
         tiplabwidth  <- max(stringWidth(tipLabels(phy)))
     } else {tiplabwidth <- unit(0, 'null', NULL)}
-    datalabwidth <- max(stringWidth(colnames(tipdata)))
-    
+
     ## 2x2 layout -- room at the bottom for data labels, and legend
     bublayout <- grid.layout(nrow = 2, ncol = 2,
         widths  = unit.c(unit(1, 'null', NULL), tiplabwidth), 
-        heights = unit.c(unit(1, 'null', NULL), datalabwidth * 1.2))
+        heights = unit.c(unit(1, 'null', NULL), dlabwdth))
     pushViewport(viewport(
         x = 0.5, y = 0.5, 
         width = 0.95, height = 1, 
@@ -392,6 +392,7 @@
         ## if ther are missing values plot Xs
         grid.points(naxs, nays, pch = 4)
     }
+    
     if(square) {
         ## alternative to circles
         ## to keep the squares square, yet resize nicely use the square npc
@@ -428,7 +429,9 @@
     ## data.label.space <- convertX(unit(1, 'npc'), "points", valueOnly = TRUE)
     ## data.label.fontsize <- data.label.space / ncol(tipdata)
     ## , gp=gpar(fontsize=data.label.fontsize))
-    grid.text(colnames(tipdata), xpos, .9, rot = 90, just = 'right')
+    ## offset the data labels from the bottom bubble
+    datalaboffset <- convertUnit(unit(15, "mm"), 'npc', valueOnly=TRUE)
+    grid.text(colnames(tipdata), xpos, 1-datalaboffset, rot = 90, just = 'right')
 
     upViewport(3)
     pushViewport(viewport(layout.pos.row=2, layout.pos.col=1,



More information about the Phylobase-commits mailing list