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

From: Rory Winston <rory.winston_at_gmail.com>
Date: Sun, 08 Jun 2008 12:07:40 +0100


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



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sun 08 Jun 2008 - 11:11:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 08 Jun 2008 - 12:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive