Phylomoji with ggtree and emojifont

May 16, 2017

(This article was first published on R on Guangchuang YU, and kindly contributed to R-bloggers)

With ggtree (Yu et al. 2017), it is very easy to create phylomoji. Emoji is internally supported by ggtree.

Use emoji in taxa labels

tree_text <- "(((((cow, (whale, dolphin)), (pig2, boar)), camel), fish), seedling);"
x <- read.tree(text=tree_text)
ggtree(x, linetype="dashed", color='firebrick') +
    xlim(NA, 7) + ylim(NA, 8.5) +
    geom_tiplab(aes(color=label), parse='emoji', size=14, vjust=0.25) +
    labs(title="phylomoji", caption="powered by ggtree + emojifont")

p <- ggtree(x, layout='circular') +
    geom_tiplab2(aes(color=label), parse='emoji', size=12, vjust=0.25)

open_tree(p, angle=200)

open_tree(p, angle=60) %>% rotate_tree(-75)

Labeling clades using emoji

tr <- rtree(30)
ggtree(tr) + xlim(NA, 5) +
    geom_cladelabel(node=41, label="chicken", parse="emoji",
                    fontsize=12, align=TRUE, color="firebrick") +
    geom_cladelabel(node=51, label="duck", parse="emoji",
                    fontsize=12, align=TRUE, color="steelblue") +
    geom_cladelabel(node=32, label="family", parse="emoji",
                    fontsize=12, align=TRUE, color="darkkhaki")

Apple Color Emoji

Although R’s graphical devices don’t support AppleColorEmoji font, it’s still possible to use it. We can export the plot to svg file and render it in Safari.

p <-  ggtree(x, size=2) + geom_tiplab(size=20, parse='emoji') +
    xlim(NA, 7) + ylim(NA, 8.5) +
                  color="firebrick", alpha = .3, size=Inf)

ps = grid.export("emoji.svg", addClass=T)

Further reading

Please visit ggtree homepage,, to find out more.


Yu, Guangchuang, David Smith, Huachen Zhu, Yi Guan, and Tommy Tsan-Yuk Lam. 2017. “Ggtree: An R Package for Visualization and Annotation of Phylogenetic Trees with Their Covariates and Other Associated Data.” Methods in Ecology and Evolution 8 (1): 28–36. doi:10.11112041-210X.12628.

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 on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


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)