我们如何制作xkcd风格的图表? [英] How can we make xkcd style graphs?

查看:179
本文介绍了我们如何制作xkcd风格的图表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,民间人士已经想出了如何制作 xkcd 风格的图表in Mathematica 在LaTeX中。我们可以在R中做到吗? GGPLOT2-ERS? geom_xkcd和/或theme_xkcd?



我想在基本图形中,par(xkcd = TRUE)?我该怎么做?





作为ggplot2中的第一个刺(以下更精美地显示),将jitter参数添加到一行可以获得很好的手绘效果。所以 -

  ggplot(mapping = aes(x = seq(1,10,.1),y = seq(1, 10,.1)))+ 
geom_line(position =jitter,color =red,size = 2)+ theme_bw()

这是一个很好的例子 - 但轴和字体看起来更复杂。虽然,字体似乎解决(下面)。处理斧头是否只能将它们剔除并手工绘制?有没有更优雅的解决方案?特别是,在ggplot2中,新主题系统中的element_line可以修改为采用类似抖动的参数吗? 您可能会想要考虑以下软件包:



软件包xkcd :以XKCD风格绘制ggplot2图形。

  library(xkcd)
vignette(xkcd-intro)

一些例子(散点图,条形图):


  • 散点图:






  • 条形图:



Apparently, folk have figured out how to make xkcd style graphs in Mathematica and in LaTeX. Can we do it in R? Ggplot2-ers? A geom_xkcd and/or theme_xkcd?

I guess in base graphics, par(xkcd=TRUE)? How do I do it?

As a first stab (and as much more elegantly shown below) in ggplot2, adding the jitter argument to a line makes for a great hand-drawn look. So -

ggplot(mapping=aes(x=seq(1,10,.1), y=seq(1,10,.1))) + 
  geom_line(position="jitter", color="red", size=2) + theme_bw()

It makes for a nice example - but the axes and fonts appear trickier. Fonts appear solved (below), though. Is the only way to deal with axes to blank them out and draw them in by hand? Is there a more elegant solution? In particular, in ggplot2, can element_line in the new theme system be modified to take a jitter-like argument?

解决方案

You might want to consider the following package:

Package xkcd: Plotting ggplot2 graphics in a XKCD style.

library(xkcd)
vignette("xkcd-intro")

Some examples (Scatterplots, Bar Charts):

  • Scatterplot:

  • Bar Chart:

这篇关于我们如何制作xkcd风格的图表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆