Re: [R-sig-phylo] plot heatmap at nodes

Another possibility (maybe more flexible) is to get the coordinates of the nodes and then call rect(). Something like:
```
tr <- rcoal(10)
plot(tr, "p", FALSE)
lastPP <- get("last_plot.phylo", envir = .PlotPhyloEnv)
x <- lastPP\$xx[-(1:lastPP\$Ntip)]
y <- lastPP\$yy[-(1:lastPP\$Ntip)]
s <- 0.3
par(xpd = TRUE)
for (h in s * c(-1.5, -.5, .5))
for (v in s * c(-1.5, -.5, .5))
rect(x + h, y + v, x + h + s, y + v + s, col=sample(colors(), 9))```
```
```
with 's' the size of each cell of the heatmap, and the vectors 'h' and 'v' are calculated for a 3x3 matrix, so this can be generalized to different dimensions (even non-square). The options of rect() can be used (border, ...)
```
par(xpd = TRUE) is to make the heatmap at the root completely visible.

Best,

Emmanuel

Le 30/08/2018 à 12:45, Emmanuel Paradis a écrit :
```
```Hi Jacob,

```
It is possible to call nodelabels() several times to do something similar to what you want by playing with the adj argument which is c(0.5, 0.5) by default (ie, the label is centered on the node). You can try this:
```
tr <- rcoal(5)
plot(tr, "p", FALSE)
for (h in c(0.4, 0.5, 0.6))
for (v in c(0.4, 0.5, 0.6))
nodelabels(pch=15, col=sample(colors(), size=1), cex=2, adj=c(h, v))

```
The difficulty is to find the 1st and 3rd values of h (horizontal) and v (vertical) and this will depend on the size of the device (and the value of cex of course). Maybe there's a way to automate these calculations.
```
Best,

Emmanuel

Le 30/08/2018 à 00:12, Jacob Berv a écrit :
```
```Dear R-sig-phylo,

```
Does there exist a function to plot heatmaps at internal nodes of a tree? For example, to illustrate support values from different phylogenetic analyses — ie given a set of 3x3 matricies of support values for particular nodes.
```
```
It seems like there may be a partial (and definitely workable) solution here, using ggtree— https://rgriff23.github.io/2017/05/11/primate-phylogeny-ggtree.html <https://rgriff23.github.io/2017/05/11/primate-phylogeny-ggtree.html>, if such heatmaps are saved as raster images (about 1/2 way down). This may be the easiest solution, but it would be preferable to keep everything in vector format and all in R.
```
```
I guess I could do this by calling image() for the individual heatmaps and then just linking them up to nodes of interest in illustrator (but that feels like cheating).
```
Jake

[[alternative HTML version deleted]]

_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
```
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
```

```
Pour nous remonter une erreur de filtrage, veuillez vous rendre ici : http://f.security-mail.net/408vx1yEbQu
```

```
```
_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
```
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
```

```
```
_______________________________________________
R-sig-phylo mailing list - R-sig-phylo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
```