[R] Adding a Rotated Density Plot to an Existing Plot

Rory Winston rory.winston at gmail.com
Sun Jun 8 13:07:40 CEST 2008


Hi

Consider the following graph:

 x <- rnorm(1000)
 x <- x + exp(-x/2)
 layout(matrix(rep(c(1,1,2), 2), 2, 3, byrow=TRUE))
 boxplot(x)
 rug(jitter(x), side=2)
 plot(density(x))


What I would really like to do is to have the density plot rotated by 90 
degrees so that I can see it line up with the rug plot on the side axis. 
I cant seem to do this. I have seen references to the grid package and 
tried some examples, but I cant seem to get it to play well with the 
boxplot. Does anyone know how I can do this?

Cheers
Rory



More information about the R-help mailing list