Thursday, November 27, 2014

Bug fix in plot.contMap / plot.densityMap

A few months ago Eliot Miller reported a strange bug in contMap in which sometimes weird, white (and thus nearly invisible on a white background) text was appearing on certain parts of the plot.

For example:

## Loading required package: ape
## Loading required package: maps
## [1] '0.4.36'
## realistic tip labels

plot of chunk unnamed-chunk-1

The white text is what appears to cause the lines close to the base of the tree to be interrupted.

Well, this bug isn't quite as mysterious as it might seem at first blush. This is because to plot the outline of the phylogeny and then the contMap I use two calls to the phytools function plotSimmap internally; however to avoid plotting the labels twice I first set par(col="white"), plot the outline tree, and then set par(col="black") and plot the "contMap".

Why the text is showing up in the wrong place, on the other hand, beats me - although I'll bet it has something to do with how I am computing the label offset. Oh well. A quick fix that I have applied in the latest non-CRAN phytools version is to use par(col="transparent") instead of par(col="white"). Hopefully all plotting devices support transparency.

Here's how it works:

## Installing package into 'C:/Users/Liam/Documents/R/win-library/3.1'
## (as 'lib' is unspecified)
## inferring 'repos = NULL' from 'pkgs'
## [1] '0.4.38'

plot of chunk unnamed-chunk-2

OK, problem solved. I'm a little concerned that transparency will not be supported by all plotting devices, but hopefully this is a temporary fix & I can figure out the real problem.

That's it. Happy Thanksgiving.