Does the following code do what you want? x <- c( rnorm(50,10,2), rnorm(30,20,2) ) y <- 2+3*x + rnorm(80)
d.x <- density(x) d.y <- density(y) layout( matrix( c(0,2,2,1,3,3,1,3,3),ncol=3) ) plot(d.x$x, d.x$y, xlim=range(x), type='l') plot(d.y$y, d.y$x, ylim=range(y), xlim=rev(range(d.y$y)), type='l') plot(x,y, xlim=range(x), ylim=range(y) ) If not, be more specific in describing what you want. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Benjamin Otto Sent: Wednesday, December 20, 2006 3:55 AM To: R-Help Subject: [R] Rotating a distribution plot by 90 degrees Hi, Can I rotate a plot (e.g. a distribution plot) by 90 degrees? The barplot function provides the "horiz" command but that's not availeable for the base package functions. I found an old advice from Paul Murrell on a similar problem suggesting to use viewports (grid package). Yet I couldn't reproduce his examples successfully. And going through the examples in the current grid package help pages left me with the feeling that viewport and the plot/points function don't match because the latter automatically clears the old device. Is there some way to rotate a "plot" at all or am I forced to use the barplot function instead? Regards, Benjamin P.S.: For further explanation: I would like to plot something like +-----+-----+ | | | | 0 | 1 | | | | +-----+-----+ | | | | 2 | 3 | | | | +-----+-----+ where image 1 is some function plot in normal mode, image 2 is a function plot rotated by 90 degrees and image 3 is something depending on the two functions. -- Benjamin Otto Universitaetsklinikum Eppendorf Hamburg Institut fuer Klinische Chemie Martinistrasse 52 20246 Hamburg ______________________________________________ [email protected] 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. ______________________________________________ [email protected] 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.
