Adding 'grey' to all the 'grays' in mpl.colors

Looking through colors.py, I noticed that most of the grey cnames use the spelling 'gray' (the US standard I think), although 'lightgrey' shows up as a valid name, while 'lightgray' does not. After looking around the web a bit for what the correct html names are, I found most sites display 'gray' and 'grey' as synonymous, for all the different intensities (darkslate, light, dim, etc).

So, here's a patch that does the same, allowing ColorConverter to accept both spellings for all the intensities.

Also, just thought I'd point out that, only after using MPL for many months have I finally noticed that commands like plot() accept 'color' as a kwarg, which allows far more than just the basic 8 or so single character color names. What a great feature! I only discovered it because I had grown annoyed by the lack of an easy way to make stuff grey. Perhaps the color kwarg and the fact that it takes html names, hex values, and rgb tuples should be mentioned more explicitly in the docstrings for some of the more common plotting commands?

Cheers,

Martin

greycolors.diff (3.94 KB)

Looking through colors.py, I noticed that most of the grey cnames use
the spelling 'gray' (the US standard I think), although 'lightgrey'
shows up as a valid name, while 'lightgray' does not. After looking
around the web a bit for what the correct html names are, I found most
sites display 'gray' and 'grey' as synonymous, for all the different
intensities (darkslate, light, dim, etc).

So, here's a patch that does the same, allowing ColorConverter to accept
both spellings for all the intensities.

Thanks for the suggestion -- I did this automagically with

# add british equivs
for k, v in cnames.items():
    if k.find('gray')>=0:
        k = k.replace('gray', 'grey')
        cnames[k] = v

Note that in pylab, you can get some extra information by doing

help(colors)

colors()
    This is a do nothing function to provide you with help on how
    matplotlib handles colors.

    Commands which take color arguments can use several formats to
    specify the colors. For the basic builtin colors, you can use a
    single letter

      b : blue
      g : green
      r : red
      c : cyan
      m : magenta
      y : yellow
      k : black
      w : white

    For a greater range of colors, you have two options. You can
    specify the color using an html hex string, as in

      color = '#eeefff'

    or you can pass an R,G,B tuple, where each of R,G,B are in the
    range [0,1].

    You can also use any legal html name for a color, like 'red',
    'burlywood' and 'chartreuse'

    The example below creates a subplot with a dark
    slate gray background

       subplot(111, axisbg=(0.1843, 0.3098, 0.3098))

    Here is an example that creates a pale turqoise title

      title('Is this the best color?', color='#afeeee')

···

On 2/12/07, Martin Spacek <scipy@...431...> wrote:

# add british equivs
for k, v in cnames.items():
   if k.find('gray')>=0:
       k = k.replace('gray', 'grey')
       cnames[k] = v

Neat, that's a much better idea.

Note that in pylab, you can get some extra information by doing

help(colors)

Thanks. I really like all the new auto-generated kwarg properties that are showing up in the docstrings now. I just noticed them today as I upgraded to 0.90.

Martin

John Hunter wrote:
  > Thanks for the suggestion -- I did this automagically with

# add british equivs
for k, v in cnames.items():
   if k.find('gray')>=0:
       k = k.replace('gray', 'grey')
       cnames[k] = v

Just noticed that 'lightgrey' is still in the cnames dict, which means that 'lightgray' is an invalid name. Here's the patch.

Cheers,

Martin

lightgray.patch (780 Bytes)