From ligges at statistik.uni-dortmund.de  Sat Nov 20 19:08:05 2004
From: ligges at statistik.uni-dortmund.de (Uwe Ligges)
Date: Sat Nov 20 19:07:36 2004
Subject: [Rd] whishlist: legend - changing color of the boxes-border
In-Reply-To: <200411082107150807.11DBEB31@mail.math.fu-berlin.de>
References: <200411082107150807.11DBEB31@mail.math.fu-berlin.de>
Message-ID: <419F8805.3090803@statistik.uni-dortmund.de>

Wolski wrote:

> Hi,
> 
> Drawing a legend I would like to be able to specify the color of boxes which are drawn if fill or density is specified.
> eg.
> legend(0,40000,c("raw","LR/PR-TPS"),fill=c(1,2),col=c(1,2),density=c(20,20),angle=c(-20,45),bty="n")
> 
> Currently the color of the boxes -- border is always black and can *not* be changed. To get this option only a *minimal* change is required.
> Please consider the following code snipped copied from the function legend (package graphics).
> 
> The sensible line is marked by ###<-
> 
>  if (mfill) {
>         if (plot) {
>             fill <- rep(fill, length.out = n.leg)
>             rect2(left = xt, top = yt + ybox/2, dx = xbox, dy = ybox, 
>                 col = fill, density = density, angle = angle, 
>                 border = "black")                                                          ####<--
>         }
>         xt <- xt + dx.fill
>     }
> 
> Changing this line from 
> 
> border="black"
> to 
> 
> border=col.
> 
> Will enable to specify the color of the boxes borders.
> 
> If specifying the colors by param _fill_ the parameter _col_ is not used anyway but still available and set already to black in the parameter declaration. Therefore why not use it to specify colors to borders of boxes?
> 

No! You want to specify "col" rather than "fill" in the following example:

   plot(1:10)
   legend(3,3, c("Hello", "World"), pch=1:2, fill=c("red", "black"))


But what you can easily do to change the box color is:

   plot(1:10)
   opar <- par(fg="blue")
   legend(3, 3, "Hello World", pch=20, col="red", text.col="green")
   par(opar)


Uwe Ligges





> Yours
> /E
> 
> 
> 
> 
> 
> Dipl. bio-chem. Eryk Witold Wolski             @    MPI-Moleculare Genetic   
> Ihnestrasse 63-73 14195 Berlin                'v'                            
> tel: 0049-30-83875219                        /   \                           
> mail: witek96@users.sourceforge.net        ---W-W----                        
> http://r4proteomics.sourceforg.net
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] whishlist: legend - changing color of the boxes-border
Uwe Ligges