[R] Color of box frame in Legend (Was: Matrix barplot)

Andreas Tille tillea at rki.de
Sat Jul 26 09:55:07 CEST 2008


On Fri, 25 Jul 2008, Nutter, Benjamin wrote:

>> data <- data.frame(Year=c(2000,2001,2002),

After the great help here I have a final problem (bug in R??)
with the background color.  I would like to put my final drawing
on a dark background and thus I would like to use brigt colors
for axes etc.  This works perfectly with the following script
except for the frame around the color bars in the legend.  Just
give this a try:


data <- data.frame(Year=c(2000,2001,2002),
                      A=c(2,2,1),
                      B=c(3,1,2),
                      C=c(0,3,5))

data.mat <- as.matrix(data)[,2:4]
rownames(data.mat) <- data[['Year']]
data.mat <- t(data.mat)

textcolor="yellow"
pdf("testdata.pdf", fg=textcolor)
par(col.axis=textcolor,col.main=textcolor)

barplot(data.mat,beside=TRUE,col=rainbow(3),main="Test")
legend(x="topleft", colnames(data[,2:4]),fill=rainbow(3), inset=0.05,
        text.col=textcolor
       )


You will notice that the frame around the color bars in the legend
remains black even if I expect it to be yellow.  Did I missed something
or is this a bug in the legend drawing routine?

Kind regards

         Andreas.

-- 
http://fam-tille.de



More information about the R-help mailing list