# Re: [R] Adding a Rotated Density Plot to an Existing Plot

From: jim holtman <jholtman_at_gmail.com>
Date: Sun, 08 Jun 2008 07:21:23 -0400

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_at_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_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> 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]]

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help