What about adding a next optional parameter which would set the "darkness/lightness", such that the mapping between color and grayscale wouldn't be linear.
Easy way how to do is to add a line, e.g.
RGBmap = brighten(RGBmap,0.2)
The problem is, however, that the mapping is not smooth (as can be seen on the plot, if I do e.g. colorGray(100,1)).
I wrote something like this (independently) myself. However, it is full greyscale (i.e. black to white) and has a wider gamut of colours. It is available as the 'contrast' colourmap of the SC package (id 16233), which also has other "colour to gray" colourmaps too: 'earth', 'pinker', 'pastel'.
23 Sep 2008
The code works well but it does not use the entire gray scale range.
16 Jan 2008
Alex is my hero!
19 Aug 2007
Great for large numbers of levels, but quite poor for just a few (e.g., if you're labelling three or four lines on a plot). In fact, the code breaks for numberOfLevels < 3. But I don't believe that's the goal of the package, so that's okay.
07 Dec 2006
Colormap that unites grayscale and full color - hooray! - Where have you been all my life?!