[Rd] w0 in legend

Ben Bolker bolker@zoo.ufl.edu
Fri, 9 Jun 2000 16:21:14 -0400 (EDT)


 
  Ooops.  This is my fault.
  When extending legend() to do multiple columns, I neglected to do
anything about the case where the user specified both sides of the box
(which is actually an easy case).

  Something like the following patch should take care of it, although I
don't know if the version of legend in the unstable package is exactly the
same as what I have here.  It's pretty straightforward, though.

*** legend.R.old Tue Jun  6 18:31:11 2000
--- legend.R	 Fri Jun  9 16:08:55 2000
***************
*** 95,100 ****
--- 95,101 ----
          top  <- y[2]
          w <- diff(x)# width
          h <- diff(y)# height
+         w0 <- w/ncol # column width
  
  	x <- mean(x)
  	y <- mean(y)


  Also, here's a set of examples that tests the full box specification,
with one or two columns.  This could go in the examples for legend() but
need not (but if it had been there running the examples would have found
the bug!)

set.seed(1001)
x1 <- runif(30)
x2 <- rnorm(30,mean=0.5)
x3 <- rnorm(30,mean=0.5,sd=0.05)
matplot(1:30,cbind(x1,x2,x3),col=1:3,pch=1:3)
legstr <- c("foo","bar","bletch")
legend(c(20,par("usr")[2]),c(2.0,par("usr")[4]),
       legstr,
       bg="gray",
       col=1:3,
       pch=1:3)
legend(c(20,par("usr")[2]),c(1.6,2.0),
       legstr,
       bg="lightblue",
       col=1:3,
       pch=1:3,
       ncol=2)


On Fri, 9 Jun 2000, Paul Gilbert wrote:

> In Version 1.1.0 Under development (unstable) (June 8, 2000)
> there seems to be a problem with an internal variable w0 in legend that
> generates the following new error:
> 
> Error in legend((par()$usr)[1:2], (par()$usr)[3:4], Legend, lty = lty,  :
>  Object "w0" not found
> >
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 
> 

-- 
Ben Bolker                                  bolker@zoo.ufl.edu
Zoology Department, University of Florida   http://www.zoo.ufl.edu/bolker
318 Carr Hall/Box 118525                    tel: (352) 392-5697
Gainesville, FL 32611-8525                  fax: (352) 392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._