最近看一个画图的公众号,基本上通篇是代码,最后上个图,我觉得作者就只想表达「哇,我好牛逼」,读者看完可能也只是发出一句「好牛逼」,然后就没有然后了。且不说他读的数据是他电脑上的,你拿了代码也不好重复,最主要是代码死长,缺少解释!

我的写作风格则不一样,一篇文章我一般只会讲解一个点,力图讲清楚,让别人看明白。比如bootstrap分段标记这一篇,代码足够短且简单,但我还是分模块来讲,一行画树,一行做bootstrap分段标记,最后一行修图,虽然三行,但按功能分开,再加上文字解释,读懂是必须的。再比如纯代码生成banner​也是分成加载中文字体、读图、图上嵌图三块。即使简单的代码,也要分模块配以文字解析。

我每次只讲解一个点,但有些知识点是关联的,所以有可能会有断片的情况出现,比如之前写phylomoji,就有同学表示没看懂,这个用到了ggtree和emojifont,两个包我都写过很多文介绍,所以在写phylomoji时都没有介绍,如果没看过以前文章的人,可能就不清楚了。所以呢,适当的时候,汇总一下,是很有必要的。

emojifont包我基本上都介绍完了,如果你能通读这几篇文章,那么你必然能够用emoji来作图装逼,能够用emoji来娱乐自己,就像我用emoji给自己快乐一样!

Continue reading

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

Use emoji in taxa labels

library(ggtree)
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")

Continue reading

use emoji font in R

![](http://guangchuangyu.github.io/blog_images/2015/Screenshot 2015-12-16 10.55.49.png)

I have played with emoji in R for a while. My solution of using it is different from what implemented in emoGG.

emoGG is a good attemp to add emoji in ggplot2. It render emoji picture (png) and creat a layer, geom_emoji, to add emoji.

In my opinion, emoji should be treated as ordinary font in user interface, albeit it maynot be true internally.

It would be more flexible if we can use emoji as ordinary font and in this way user don’t need to learn extra stuff.

Continue reading

Author's picture

Guangchuang Yu

Bioinformatics Professor @ SMU

Bioinformatics Professor

Guangzhou