[R] Legend with fill = gray ?

Jens Oldeland oldeland at gmx.de
Wed Sep 1 22:43:29 CEST 2010


Hi,

sorry for beeing unprecise. I am looking for a legend that has the same
colors as the barplot. For a coloured version I would simply use the
same fill=rainbow() option as used in creating the barplot. However,
this does not work when there are gray values, because there are not
defined in the barplot command. So, finally, the legend for the gray
scale figure needs a certain "fill=XXXX" command. 0.1:0.3 did not work,
of course, I thought this would be quite obvious.

Any idea how to get the legend in the right shape?

Thanks!

Greg Snow schrieb:
> The phrase "does not work" can mean many things, it would help us to help you if you spelled out what you expected and how what you saw differs from what was expected.
> 
> I suspect part of your problem may be in using 0.1:0.3, did you try typing just that at the command line to see the result?  The ':' operator increments by 1 up until the largest values less than or equal to the right side, in this case it returns the single value 0.1.
> 
> Barplot uses the gray.colors function when you don't specify the colors, perhaps using that will work for you.  Or you could always pass specific shades of grey like you pass specific colors, then you don't need to guess or search.
>



More information about the R-help mailing list