I want to make a plot that is similar to beanplot or violin plot, but instead of the symmetric shapes, i want to plot two different distributions on the different sides of the center line. Something like figure 4 in this article [pdf]http://www.jstatsoft.org/v28/c01/paper.
I want to use the grid graphics engine in R. Any pointers will be useful. I looked at the lattice package and the histogram function in lattice package, but that is not what i want to do.
Any help/pointers are appreciated.
You can reasonably easily get the half-violin plot with fairly simple modifications to the function,
panel.violinin Sarkar’s lattice package. There are four lines in that function that can be altered inside thegrid.polygoncall to change from “two-sided” density plotting to single sided density plotting. Firstrequire(lattice)andrequire(grid). Then typepanel.violin. I’ll show you the “horizontal” alteration:Also remove it from the corresponding section in the else{ …} clause. Now you can run it with the example in help(panel.violin)
If you wanted the density on the other side, all you would need to do would be remove the dx.list[[i]] and dy.list[[i]] and leave in the
rev(dx.list[[i]])and-rev(dy.list[[i]]).