微软以75亿美元收购全球最大的单身交友网站GitHub,应景分享一张图片,其实这图大家并不陌生,在《听说你还不会画热图》一文中,大家早已见过。
这图实在太好玩,被套在各种场景上,今天就要教大家怎么用R,纯代码生成这样的图,简直是吐槽神器。这类图可以归入meme,画meme,当然少不了我写的meme包,这包收录在CRAN中,点击下面链接了解一下:
很多人都在学ggplot2
,也有很多「高手」,比如你搜索「精通ggplot2」,你甚至会看到各种「从入门到精通」的课程,然而都是各种照猫画老虎的入门菜谱而已,当然广大群众去上课也可能只是为了求菜谱好在需要的时候,可以copy-paste而已。
ggplot2
学习容易,因为无非是图层叠加,而图层的参数一致性非常好,网上也有很全的文档。然而要深入很难,比如你想干点什么是ggplot2
自身没有支持的,你需要自己去hack,需要用到更底层的东西的时候,一般情况下,会无从入手,尝试之后才知道什么叫绝望!因为ggplot2
套路实在是太深。
正如我在《听说你还不会画热图》吐槽的,有些所谓的「高手」实际上连ggplot2
底层是什么都不知道!然后可以把ggplot2
吹上天。很多人根本不知道当你打下ggplot
这个命令的时候,到底发生了什么?要理解ggplot2
并不容易,正如前面所说「套路太深」,没有金钢钻,读不了它的代码,有没有一个简单点的包,能够读懂代码,并且有助于理解ggplot2
呢?我想我的meme
包就非常好,虽然仿的有点肤浅,然而胜在简单,看过下面这两篇文章的,都知道这个包在做什么。
meme无非是照片上加两行字,meme这个包本来是练手之作,用来模拟ggplot2的api。结果我后面又实现了字体阴影效果,这次我又带来了外部字体支持。
加载外部字体在R上面主要有extrafont和showtext两个实现,特别是showtext用起来还是非常简单的。我在meme包里写了font_import
函数,内部就是用showtext,只是简单的包装了一下,这样小白用户可以直接下个字体就开撸。有阴影效果,有搞笑字体,就万事具备了,这俨然是个专业的meme工具了。
After the release of meme
package, I received several feedbacks from users.
The most usefule one is the comment on my blog post:
Greetings Mr. Yu,
I am very happy that this package exists. Thank you for making it! I would like to request a feature, to ensure the package is able to compete with professional meme-creation tools like memegenerator and paint.net. Since memes often use the font Impact, in white and with black outline, I believe the package would be more powerful if it also did that automatically.
Regards,
The words, ‘compete with professional meme-creation tools’, stimulated me to develop text plotting with background outline effect.
Now this feature is available in meme v>=0.0.7, which can be downloaded from CRAN.
Sercan Kahveci
Greetings Mr. Yu,
I am very happy that this package exists. Thank you for making it! I would like to request a feature, to ensure the package is able to compete with professional meme-creation tools like memegenerator and paint.net. Since memes often use the font Impact, in white and with black outline, I believe the package would be more powerful if it also did that automatically.
Regards,
Sercan Kahveci, MSc
Content creator at Questionable Research Memes on Facebook https://www.facebook.com/QResearchMemes/
上次一篇《用R画meme ;)》把脸书在做MEME的人都给炸出来了,专业人士给出专业建议,要用Impact字体,并且要让字体出现阴影效果,这真是厉害了,感觉有点神奇,但他一句,这样就可以和专业工具PK了,着实太刺激了,我决定试一试能不能搞个阴影效果。结果还真让我搞成了,文本有一种浮在上面的错觉。
我们知道meme包是grid写的,我的输出是grob对象,当我半夜调试到2点,带着兴奋入睡之后,一点都睡不安稳,早上早早就迷迷糊糊在床上想着,既然我造出了文本阴影效果的grob对象,我应该封装成geom图层,送给ggplot2用户。
I developed a tiny toy package, meme
, which is now on CRAN. As it’s name indicated, it was designed to create memes, which are captioned photos that are intended to be funny, riduculous.
meme()
The package is quite simple. You can use meme()
function to add meme captions, and this is all the package supposed to do:
library(meme)
u <- "http://www.happyfamilyneeds.com/wp-content/uploads/2017/08/angry8.jpg"
meme(u, "code", "all the things!")