Repository: matplotlib/matplotlib
Pull request: added alias to gray and grey match same colormaps
## PR summary
Closes #8965 

As suggested in the issue discussion, added alias to match the different spellings of gray and grey in the end of _gen_cmap_registry function in cm.py

    cmap_d['grey'] = cmap_d['gist_grey'] = cmap_d['gray']
    cmap_d['Grays'] = cmap_d['Greys']
    cmap_d['gist_yerg'] = cmap_d['gist_yarg'] = cmap_d['gray_r']
    cmap_d['grey_r'] = cmap_d['gray_r']

## PR checklist
<!-- Please mark any checkboxes that do not apply to this PR as [N/A].-->

- [x] "closes #0000" is in the body of the PR description to [link the related issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
- [N/A] new and changed code is [tested](https://matplotlib.org/devdocs/devel/testing.html)
- [N/A] *Plotting related* features are demonstrated in an [example](https://matplotlib.org/devdocs/devel/documenting_mpl.html#writing-examples-and-tutorials)
- [N/A] *New Features* and *API Changes* are noted with a [directive and release note](https://matplotlib.org/devdocs/devel/coding_guide.html#new-features-and-api-changes)
- [x] Documentation complies with [general](https://matplotlib.org/devdocs/devel/documenting_mpl.html#writing-rest-pages) and [docstring](https://matplotlib.org/devdocs/devel/documenting_mpl.html#writing-docstrings) guidelines

<!--
Thank you so much for your PR!  To help us review your contribution, please
consider the following points:

- A development guide is available at https://matplotlib.org/devdocs/devel/index.html.

- Help with git and github is available at https://matplotlib.org/devdocs/devel/development_workflow.html

- Create a separate branch for your changes and open the PR from this branch. Please avoid working on `main`.

- The PR title should summarize the changes, for example "Raise ValueError on
  non-numeric input to set_xlim".  Avoid non-descriptive titles such as
  "Addresses issue #8576".

- The summary should provide at least 1-2 sentences describing the pull request
  in detail (Why is this change required?  What problem does it solve?) and
  link to any relevant issues.

- If you are contributing fixes to docstrings, please pay attention to
  https://matplotlib.org/stable/devel/documenting_mpl.html#formatting-conventions.  In particular,
  note the difference between using single backquotes, double backquotes, and
  asterisks in the markup.

We understand that PRs can sometimes be overwhelming, especially as the
reviews start coming in.  Please let us know if the reviews are unclear or
the recommended next step seems overly demanding, if you would like help in
addressing a reviewer's comments, or if you have been waiting too long to hear
back on your PR.
-->


Problem statement:
Add alias for colormaps for grey vs gray English issues
<!--To help us understand and resolve your issue, please fill out the form to the best of your ability.-->
<!--You can feel free to delete the sections that do not apply.-->

### Bug report

**Bug summary**

The current colormap options reflect American English spellings for 2/3 of the colormaps with a flavor of gray. An alias to the gray definitions using the standard UK spelling of grey would be helpful.

Colormaps that would need aliases for the UK spelling include:
gray, gray_r, nist_gray, nist_gray_r

Colormaps that use the UK spelling and would want an American English alias are:
Greys, Greys_r

Hints from issue discussion:
I don't mind making things uniform by moving towards either direction (well I have no horse in this game :-)) but I'm quite strongly against adding more aliases -- it's not as it matplotlib's API ever claimed to be localized anyways (I'm not a native English speaker but I'm not going to complain that I have to write `plot(...)` instead of `représente_graphiquement(...)`).
Just to note, this discrepancy appeared during my tutorial right after I
pointed out that any instances of "gray" in a colorname can also be "grey".
So, the colormaps are inconsistent with the colors system, in this respect.

On Sun, Jul 30, 2017 at 3:11 PM, Antony Lee <notifications@github.com>
wrote:

> I don't mind making things uniform by moving towards either direction
> (well I have no horse in this game :-)) but I'm quite strongly against
> adding more aliases -- it's not as it matplotlib's API ever claimed to be
> localized anyways (I'm not a native English speaker but I'm not going to
> complain that I have to write plot(...) instead of
> représente_graphiquement(...)).
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/matplotlib/matplotlib/issues/8965#issuecomment-318922764>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AARy-OOPSizwHW8gf4Cx0jLQa0EdFHyJks5sTNVYgaJpZM4Ont0K>
> .
>

In general, I'm against more helper aliases. In this case however, it's a pretty annoying usability flaw. The cost of adding the alias is much less than the annoyance this causes new users, or even repeat users, like me.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear.  Thanks for your help!
We should do this. This is a usability issue and a consistency issue (color names supporting both but coloraps names not).

Implementation:  I suggest to just re-register a copy of the colormaps with the respective other name. This should be done in https://github.com/matplotlib/matplotlib/blob/b3bd929cf07ea35479fded8f739126ccc39edd6d/lib/matplotlib/cm.py#L33, which also creates the reverse colormaps.
Sure, I don't really mind anymore.
Note, however, that there's currently both "gray" and "Greys" which are *not* the same colormaps ("gray" is plain linear, "Greys" is not).  There's also gist_gray, which is I think(?) exactly the same as "gray" (and gist_yarg, which is the same as "gray_r").
We just have to make sure that `gist_yarg` is aliased to ` gist_yerg`...
> We just have to make sure that `gist_yarg` is aliased to ` gist_yerg`...

And `matplotlib` to `metplotlib` 🤣 

> And `matplotlib` to `metplotlib` 🤣 

As [MetOffice](https://github.com/MetOffice) representative, I approve this plan 😆
Hi! I was thinking about starting to contribute to this repository and found this good first issue which does not seems too difficult, although I also noticed that not everyone agrees on this issue about adding more aliases, so I would like to know if I can work on this issue or isn't necessary anymore?

Commit message: added alias to gray and grey match same colormaps

Patch to review:
diff --git a/lib/matplotlib/cm.py b/lib/matplotlib/cm.py
index 38158db9564a..d9796cd4deea 100644
--- a/lib/matplotlib/cm.py
+++ b/lib/matplotlib/cm.py
@@ -46,6 +46,13 @@ def _gen_cmap_registry():
     for cmap in list(cmap_d.values()):
         rmap = cmap.reversed()
         cmap_d[rmap.name] = rmap
+
+    # Register colormap aliases for gray and grey.
+    cmap_d['grey'] = cmap_d['gist_grey'] = cmap_d['gray']
+    cmap_d['Grays'] = cmap_d['Greys']
+    cmap_d['gist_yerg'] = cmap_d['gist_yarg'] = cmap_d['gray_r']
+    cmap_d['grey_r'] = cmap_d['gray_r']
+
     return cmap_d
 
 


Code review comments:
diff_hunk: @@ -46,6 +46,13 @@ def _gen_cmap_registry():
     for cmap in list(cmap_d.values()):
         rmap = cmap.reversed()
         cmap_d[rmap.name] = rmap
+
+    # Register colormap aliases for gray and grey.
+    cmap_d['grey'] = cmap_d['gist_grey'] = cmap_d['gray']
path: lib/matplotlib/cm.py
text: @user1:
Let's not make assumptions on equivalence and instead plainliy assign by the naming alias.
```suggestion
    cmap_d['grey'] = cmap_d['gray']
    cmap_d['gist_grey'] = cmap_d['gist_gray']
```
Please also move this section to before "Generate reversed cmaps" so that you do not need to handle the `*_r` cases yourself.