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
This gets you close to the solution that you want: 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) y <- density(x) plot(y$y, y$x, type='l') On Sun, Jun 8, 2008 at 7:07 AM, Rory Winston <rory.winston@gmail.com> wrote:> 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@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]
I forgot to make sure the axis ranges were the same: x <- rnorm(1000) x <- x + exp(-x/2) layout(matrix(rep(c(1,1,2), 2), 2, 3, byrow=TRUE)) boxplot(x, ylim=c(0.5,4)) rug(jitter(x), side=2) y <- density(x) plot(y$y, y$x, type='l',ylim=c(0.5,4)) On Sun, Jun 8, 2008 at 7:07 AM, Rory Winston <rory.winston@gmail.com> wrote:> 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@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]]