[Phylobase-devl] What I did with my summer vacation -- phylobase plotting

Peter Cowan pdc at berkeley.edu
Thu Aug 7 06:43:34 CEST 2008

Hi all,

Steve and I held a bit of a mini hackathon trying to wrap up some of
the loose ends with my Google Summer of Code project, a new plotting
interface.  The google thing ends has a hard deadline of the 18th.
Before that time, I wanted to show the rest of the team where I am and
see what bugs you could find or features that would be handy.  To get
the code you'll need to install phylobase from the pdcgsoc branch,
which is easily done by changing to the branch directory and running R
CMD INSTALL pdcgsoc/

Nearly all the code I've written can be found in the treePlot.R file.
However there is only one end user interface, the treePlot() function.
 Here are examples showing the some features already implemented.

When running the examples, resize the plots to see some of the grid magic.

I'm quite confident there will be bugs, particularly with edge cases,
but I haven't found them yet, so please let me know if you have
trees/parameter combinations that don't work.  I also haven't
validated everything, I'm confident the node and tip labels show up at
the right nodes, but less confident the data plot and edge coloring is
proper, so don't be surprised if you find errors there -- please let
me know if you do!

Also suggestions for where this belongs in the package are welcome, do
we want to keep the current default plotting methods, do they have
function that can be rolled into the new commands?




# for phylo4 objects
treePlot(as(geospiza, 'phylo4'))

# familiar -- yet rebuilt -- data default
treePlot(geospiza, square = TRUE)

# a different approach to data plotting
# native grid plotting functions work quite well
ff <- function(x) {grid.rect(); grid.points()}
treePlot(geospiza, tip.plot.fun = ff)

# this will require the gridBase package
# there is an interface for base graphs, shown by the built in 'density' option
treePlot(geospiza, tip.plot.fun = 'density')

# fan style plotting
treePlot(geospiza, type = 'fan')

# tip and edge coloring
treePlot(geospiza, plot.data = FALSE,
    edge.color = rainbow(nrow(geospiza at edge)),
    tip.color = c('red',  'black', 'blue'),

# non-ultrametric trees, note the extreme ability to resize this plot
n <- 10
tree1 <- as(rtree(n), 'phylo4')
tree1 at tip.label <- replicate(n,
                paste(sample(LETTERS, sample(2:20, 1)), collapse = ""))

More information about the Phylobase-devl mailing list