	
	legend := function(x, y,  legend,  fill,  col="black",  lty,
	pch,  bty="o",  bg=par("bg"),          xjust=0,  yjust=1)  {
	        xchar  <-  xinch(par("cin")[1])           ychar   <-
	yinch(par("cin")[2])          xychar <- yinch(par("cin")[1])
	        yline  <-  2*xchar          w  <-  2   *   xchar   +
	max(strwidth(legend))          h <- (length(legend)+1)*ychar
	        x <- x - xjust * w         y <- y + (1 - yjust) *  h
	        xt <- rep(x, length(legend)) + xchar         yt <- y
	-  (1:length(legend))  *  ychar           if(!missing(fill))
	                w     <-     w     +     1.75     *    xchar
	        if(!missing(pch))                 w <-  w  +  1.5  *
	xchar         if(!missing(lty))                 w <- w + 3 *
	xchar         if(bty != "n")                 rect(x, y, x+w,
	y-h,      col=bg)             x     <-     x     +     xchar
	        if(!missing(fill)) {                 rect(xt,  yt  -
	0.4  * xychar,                         xt + 0.75 * xchar, yt
	+ 0.35 * xychar, col=fill)                 xt <- xt + 1.75 *
	xchar               }               if(!missing(pch))      {
	                points(xt + 0.25 * xchar, yt, pch,  col=col)
	                xt   <-   xt   +   1.5   *  xchar          }
	        if(!missing(lty)) {                 segments(xt, yt,
	xt  + 2 * xchar, yt, lty=lty, col=col)                 xt <-
	xt + 3 * xchar         }         text(xt,  yt,  text=legend,
	adj=c(0, 0.35)) }
	
	                      October 1, 1996
	
