Annotating phylogenetic tree with images using ggtree and ggimage

[This article was first published on R on Guangchuang YU, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

With ggimage, we are able to plot images using grammar of graphics. The layers defined in ggimage can be directly applied to ggtree to annotate phylogenetic tree using local/online image files.

ggtree seamlessly work with ggimage. The geom_tiplab and geom_nodelab can accept parameter of geom="image" to parse taxa labels as image files and use them to “label” the taxa using images instead of text strings. Here are some examples for demonstration.

Annotate tips

url <- paste0("",
x <- read.tree(paste0(url, "tree_boots.nwk"))
info <- read.csv(paste0(url, "tip_data.csv"))
p <- ggtree(x) %<+% info + xlim(NA, 6)
p + geom_tiplab(aes(image= imageURL), geom="image", offset=2, align=T, size=.16, hjust=0) +
    geom_tiplab(geom="label", offset=1, hjust=.5)

Annotate internal nodes

## example from
tree <-"")
phylopic_info <- data.frame(node = c(124, 113, 110, 96, 89, 70),
                            phylopic = c("7fb9bea8-e758-4986-afb2-95a2c3bf983d",
                            species = c("galagoids", "lemurs", "tarsiers",
                                        "cebids", "hominoids", "cercopithecoids"))
pg <- ggtree(tree)
pg %<+% phylopic_info + geom_nodelab(aes(image=phylopic), geom="phylopic", alpha=.5, color='steelblue')

d <- data.frame(node = c("70","89","96","110","113","124"),
                images = c("",
pg %<+% d + geom_nodelab(aes(image=images), geom="image")

Use image as background

pg + geom_phylopic(image="79ad5f09-cf21-4c89-8e7d-0c82a00ce728", size=Inf, alpha=.5, color='firebrick')

Here is another example that uses Tabikaeru (known as traveling frog, a popular mobile game) image to decorate a phylogenetic tree of frog, see reproducible source code on

To leave a comment for the author, please follow the link and comment on their blog: R on Guangchuang YU. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)