[R] Rotating a distribution plot by 90 degrees

Benjamin Otto b.otto at uke.uni-hamburg.de
Thu Dec 21 10:58:34 CET 2006


I forgot one thing:

Gregs example results in what I seek. However he has roteted the data in his
"mind" and in the data submitted to the plot command. What I would like to
know is whether I can use the "plot" command to make some normal plot and
add some second command which rotates the data for me...

Regards

Benjamin


-----Ursprüngliche Nachricht-----
Von: Benjamin Otto [mailto:b.otto at uke.uni-hamburg.de] 
Gesendet: 21 December 2006 10:51
An: 'Greg Snow'; 'R-Help'; 'Knut Krueger'
Betreff: Re: [R] Rotating a distribution plot by 90 degrees

 
Hi Knut, hi Greg,

Thanks for the quick help!

@Greg:
Yes THAT’S exactly what I meant. Thanks for the example.

@Knut:
Thanks for the hint. However my problem was that the combination of "plot"
and grid wasn't working. But probably it isn't supposed to.

Regards
Benjamin


----------------------------------------------------------------------------
----

Knut wrote:

> Did you find these manuals for the Grid package?

> http://www.stat.auckland.ac.nz/~paul/grid/doc/rotated.pdf

> http://www.stat.auckland.ac.nz/~paul/grid/grid.html

> Regards Knut



-----Ursprüngliche Nachricht-----
Von: Greg Snow [mailto:Greg.Snow at intermountainmail.org] 
Gesendet: 20 December 2006 20:34
An: Benjamin Otto; R-Help
Betreff: RE: [R] Rotating a distribution plot by 90 degrees

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
greg.snow at intermountainmail.org
(801) 408-8111
 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] 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

______________________________________________
R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list