I frequently use R's help facilities and I know about the asp argument to
plot, but this doesn't answer my question. I would like to allow the aspect
to be determined automatically but *query* the aspect ratio for future use.
I suppose one work-around would be to use the data ranges and plot region
dimensions to estimate an appropriate value for asp, but this more
complicated than I was hoping for.
Thanks,
Levi
On Thu, Aug 27, 2009 at 6:19 PM, Bert Gunter <gunter.berton@gene.com>
wrote:
> Use R's help facilities, please.
>
> help.search("aspect ratio")
>
> gets you to ?plot.window
>
> which then gets you to ?plot (actually plot.default() )
>
> Bert Gunter
> Genentech Nonclinical Biostatisics
>
> -----Original Message-----
> From: r-help-bounces@r-project.org [mailto:r-help-bounces@r-project.org]
> On
> Behalf Of Levi Waldron
> Sent: Thursday, August 27, 2009 1:54 PM
> To: r-help@r-project.org
> Subject: [R] setting par(srt) according to plot aspect ratio
>
> How can I look up the aspect ratio of a plot, so I can use that to
> correctly
> adjust the angle of text which is supposed to be parallel to a line in the
> plot?
>
> The following example code works for a 1:1 aspect ratio, but puts the text
> at the wrong angle if the plot region is short and wide or tall and narrow.
> I can't find a par() component containing the plot aspect ratio. It
will
> be for png() or postscript() output, if that matters.
>
> f <- function(x) x
> g <- function(x) 2*x
> (f_angle <- atan(1)*180/pi)
> (g_angle <- atan(2)*180/pi)
> xpos <- 0.2
> plot(f)
> plot(g,add=TRUE)
> par(srt=f_angle)
> text(xpos,f(xpos),label="y=x",pos=3)
> par(srt=g_angle)
> text(xpos,g(xpos),label="y=2x",pos=3)
>
>
> --
> Levi Waldron
> post-doctoral fellow
> Jurisica Lab, Ontario Cancer Institute
> Division of Signaling Biology
> TMDT 9-304D
> 101 College Street
> Toronto, Ontario M5G 1L7
> (416)581-7453
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>
>
--
Levi Waldron
post-doctoral fellow
Jurisica Lab, Ontario Cancer Institute
Division of Signaling Biology
TMDT 9-304D
101 College Street
Toronto, Ontario M5G 1L7
(416)581-7453
[[alternative HTML version deleted]]