R graphs: Creating Tufte's horizontal bar lines

前端 未结 3 676
礼貌的吻别
礼貌的吻别 2020-12-14 02:39

How can we replicate Tufte\'s implicit horizontal lines in R?

\"Tufte

For example, the following

3条回答
  •  甜味超标
    2020-12-14 03:22

    Not a big addition to @Andrie answer, but you can take an advantage of the package ggthemes to make Tufte-sque plots with ggplot2. Below, I'm using theme_tufte, change the font using extrafont package, and use opts to fine-tune all the other visual features:

    library(ggthemes)
    library(extrafont)
    ggplot(msleep, aes(x=order)) + stat_bin(width=0.6, fill="gray") + 
      theme_tufte(base_family="GillSans", base_size=16, ticks=F) +
      theme(axis.line=element_blank(), axis.text.x=element_blank(),
            axis.title=element_blank()) +
      geom_hline(yintercept=seq(5, 20, 5), col="white", lwd=1.2)
    

    enter image description here

提交回复
热议问题