[R] Vaseplots

Liaw, Andy andy_liaw at merck.com
Mon Jul 12 21:47:34 CEST 2004

I don't have that article handy, but it sounds like `violin plots' that I've
read (also in Am. Stat.) quite a while ago.  I wrote a S-PLUS function to do
something like it back in the dark ages.  It probably isn't too hard to
modify for use with R.  See if it does something similar:

violin.plot<-function(y, x=NULL, ...) {
    if (is.null(x)) {
        cx <- boxplot(y,style.bxp='old')
        den.y <- ksmooth(y,ker='n')
    } else {
        if (!is.factor(x)) x<-factor(x)
        cx <- boxplot(split(y,x),style.bxp='old')
        for(i in 1:length(lev.x)) {

[Note that I had to do quite a bit of fudging to get the x-coordinates sort
of right in S-PLUS.  In R this is a LOT easier.]


> From: Peter Flom
> In The American Statistician vol 42 (1988) pages 257 - 280, Yoav
> Benjamini investigates some variations on the box plot, including
> vaseplots, which maek the width of each box vary proportionally to he
> estimated density at a particular point.
> Has anyone implemented these in R ?
> Thanks as always
> Peter

More information about the R-help mailing list