[R] Legend with fill = gray ?

Jens Oldeland oldeland at gmx.de
Wed Sep 1 22:17:25 CEST 2010


Hi,

I am facing a problem with the legend, I don´t know how to use the fill
option in the legend in order to achieve the same standard gray levels
that are plotted.

Sorry for this easy one, but I really did not find anything so far.

It works fine with color:

###### C O L O R
mat <- matrix(2,3,rep(2,6))
rownames(mat)<-c("A","B","C")
par(xpd=T, mar=par()$mar+c(2,0,0,0))
barplot(mat,col=rainbow(3))
legend(1,-2,legend=rownames(mat),fill=rainbow(3))

however

### G R A Y  ??

par(xpd=T, mar=par()$mar+c(2,0,0,0))
barplot(mat)  # now without color
legend(1,-2,legend=rownames(mat),fill=gray(0.1:0.3)) # this gray does
not work

could anyone help me out, please?
Thank you!

Jens



More information about the R-help mailing list