The gridBase package supports the mixing of traditional graphs in grid 
viewports, that may do what you want (But I am not a grid expert, so can't tell 
you anything more on that).  You could also create a plot, save it as a 
graphics file, read it back in rotated and add it to a plot, but that seems 
like even more work.

You will want to be careful and think things through even if you find an easy 
way to rotate the plots, if you do the default plot of a density, rotate it and 
put it next to a scatterplot, then the axes are unlikely to line up correctly 
(that is why my example explicitly sets xlim and ylim).  It seems to me that 
once you think through everything needed to get the axes to line up, switching 
the x and y arguments is simpler than calling another function to rotate things 
(unless of course the plot you want to rotate is an already canned routine that 
does not have a horiz argument or works just by switching x and y). 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 

-----Original Message-----
From: Benjamin Otto [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 21, 2006 2:59 AM
To: Greg Snow; 'R-Help'; 'Knut Krueger'
Subject: AW: [R] Rotating a distribution plot by 90 degrees

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:[EMAIL PROTECTED]
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:[EMAIL PROTECTED]
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
[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.

Reply via email to