[Phylobase-commits] r280 - branches/pdcgsoc/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Aug 12 08:09:21 CEST 2008
Author: pdc
Date: 2008-08-12 08:09:21 +0200 (Tue, 12 Aug 2008)
New Revision: 280
Modified:
branches/pdcgsoc/R/treePlot.R
Log:
small tweaks and comments
Modified: branches/pdcgsoc/R/treePlot.R
===================================================================
--- branches/pdcgsoc/R/treePlot.R 2008-08-12 05:57:34 UTC (rev 279)
+++ branches/pdcgsoc/R/treePlot.R 2008-08-12 06:09:21 UTC (rev 280)
@@ -382,20 +382,25 @@
## tys <- tys * (1 - (2 * maxr)) + maxr
xrep <- rep(xpos, each = length(tys))
yrep <- rep(tys, nVars)
+ ## color bubbles
ccol <- ifelse(tipdata < 0, 'black', 'white')
+ ## generate matrices of every x and y, then subset for datapoints that are NA
naxs <- matrix(xrep, ncol = nVars)
nays <- matrix(yrep, ncol = nVars)
dnas <- is.na(tipdata)
naxs <- naxs[dnas]
nays <- nays[dnas]
+ ## set the NA points to zero so that grid.circle doesn't crash
tipdata[is.na(tipdata)] <- 0
+ ## get label widths
tiplabwidth <- max(stringWidth(phy at tip.label))
- datalabwidth <- max(stringWidth(colnames(tipdata))) * 1.2
+ 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))
+ heights = unit.c(unit(1, 'null', NULL), datalabwidth * 1.2))
pushViewport(viewport(
x = 0.5, y = 0.5,
width = 1, height = 1,
@@ -407,25 +412,31 @@
layout.pos.row = 1
))
if(grid) {
+ ## draw light grey grid behind bubbles
grid.segments(x0 = 0, x1 = 1,
y0 = tys, y1 = tys, gp = gpar(col = 'grey'))
grid.segments(x0 = xpos, x1 = xpos,
y0 = 0, y1 = 1, gp = gpar(col = 'grey'))
}
if (length(naxs) > 0) {
+ ## if ther are missing values plot Xs
grid.points(naxs, nays, pch = 4)
}
if(square) {
- # to keep the squares square, yet resize nicely use the square npc
+ ## alternative to circles
+ ## to keep the squares square, yet resize nicely use the square npc
sqedge <- unit(unlist(tipdata), 'snpc')
grid.rect(x = xrep, y = yrep,
width = sqedge,
height = sqedge,
gp=gpar(fill = ccol))
} else {
+ ## plot bubbles
grid.circle(xrep, yrep, r = unlist(tipdata), gp = gpar(fill = ccol))
}
upViewport()
+
+ ## push view ports for tip and data labels
pushViewport(viewport(
name = 'bubble_tip_labels',
layout = bublayout,
@@ -441,7 +452,6 @@
layout.pos.row = 2
))
grid.text(colnames(tipdata), xpos, .65, rot = 90, just = 'right')
- upViewport()
- upViewport()
+ upViewport(2)
}
More information about the Phylobase-commits
mailing list