Functions available for Tufte boxplots in R?

后端 未结 5 756
感动是毒
感动是毒 2020-12-08 05:27

I have some data that I\'ve divided into enough groupings that standard boxplots look very crowded. Tufte has his own boxplots in which you basically drop all or half of bo

5条回答
  •  感情败类
    2020-12-08 05:54

    Here is a solution without using any packages, just manipulating boxplot pars graphical parameters. My suggestion is closest to @DWin, but getting rid of colour and axes, and using just few lines of code. Both suggestions by @gsk3 and @Ramnath are very good, and much more advanced than mine, but if I may comment - they fail to address Tufte's main philosophy. If we would get rid of gray background, white 'prison bars' and unnecessary colours, all solutions above would gain in clarity, simplicity and right data-ink balance.

    Credits should go to creators of PerformanceAnalytics, who included cute chart.Boxplot wrapper inspired by Tufte work. I simply extracted some elements of function to keep it even simpler. Just attach 'cw' sample data above from @gsk3.

    attach(cw)
    par(mfrow=c(1,3))
    boxplot(weight~Time, horizontal = F, main = "", xlab="Time", ylab="Weight", 
            pars = list(boxcol = "white", medlty = "blank", medpch=16, medcex = 1.3, 
            whisklty = c(1, 1), staplelty = "blank", outcex = 0.5), axes = FALSE)
    axis(1,at=1:4,label=c(1:4))
    axis(2)
    boxplot(weight~Chick, horizontal = F, main = "", xlab = "Chick", 
            ylab = "", pars = list(boxcol = "white", medlty = "blank", medpch=16, 
            medcex = 1.3, whisklty = c(1, 1), staplelty = "blank", outcex = 0.5), 
            axes = FALSE)
    axis(1,at=1:3,label=c("A","B","C"))
    boxplot(weight~Diet, horizontal = F, main = "", xlab = "Diet", ylab = "", 
            pars = list(boxcol = "white", medlty = "blank", medpch=16, medcex = 1.3, 
            whisklty = c(1, 1), staplelty = "blank", outcex = 0.5), axes = FALSE)
    axis(1,at=1:4,label=c("LoFat","HiFat","LoProt","HiProt"))
    

    enter image description here

提交回复
热议问题