How can we make xkcd style graphs?

前端 未结 7 1463
心在旅途
心在旅途 2020-11-28 00:12

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 i

7条回答
  •  Happy的楠姐
    2020-11-28 00:36

    Here is my take on the lines with ggplot2 using some of the code from above:

    ggplot()+geom_line(aes(x=seq(0,1,length.out=1000),y=sin(x)),position=position_jitter(width=0.02),lwd=1.5,col="white")+
      geom_line(aes(x=seq(0,1,length.out=1000),y=sin(x)),position=position_jitter(width=0.004),lwd=1.4,col="red")+
      geom_line(aes(x=seq(0,1,length.out=1000),y=cos(x)),position=position_jitter(width=0.02),lwd=1.5,col="white")+
      geom_line(aes(x=seq(0,1,length.out=1000),y=cos(x)),position=position_jitter(width=0.004),lwd=1.4,col="blue")+
      theme_bw()+theme(panel.grid.major=element_blank(),panel.grid.minor=element_blank())
    

    Not sure how to replace the axes, but could use the same approach with jitter. Then it's a matter of importing the font from XKCD and layering with geom_text.

提交回复
热议问题