From marc_schwartz at comcast.net  Tue Jan 23 17:02:10 2007
From: marc_schwartz at comcast.net (Marc Schwartz)
Date: Tue, 23 Jan 2007 10:02:10 -0600
Subject: [Rd] can't plot a line
In-Reply-To: <45B62CC6.1020008@pdf.com>
References: <45B62CC6.1020008@pdf.com>
Message-ID: <1169568130.4816.20.camel@localhost.localdomain>

On Tue, 2007-01-23 at 07:41 -0800, Spencer Graves wrote:
> Consider the following: 
> 
>       plot(0, 0, xlim=c(-10, 10), ylim=c(-50, 50))
>       lines(c(0,0), (2*c(-pi, pi))^2)
> 
>       I see no line in this plot. 
> 
> R version 2.4.1 (2006-12-18)
> i386-pc-mingw32
> 
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
> States.1252;LC_MONETARY=English_United 
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods" 
> [7] "base"    
> 
>       My work around is the following: 
> 
>       pi2.2 <- (2*pi)^2
>       lines(c(0, 0), c(-pi2.2, pi2.2))
> 
>       Why won't "lines(c(0,0), (2*c(-pi, pi))^2)" work for me? 
>       Thanks,
>       Spencer Graves

In the first case, you are squaring 2*pi and 2*-pi, both resulting in
the same positive number:

> (2*c(-pi, pi))^2
[1] 39.47842 39.47842

You are going from (0,39.47842) to (0,39.47842), hence no line.

HTH,

Marc Schwartz



[Rd] can't plot a line
Marc Schwartz