-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Doc]: document how to get list of registered colormaps #26244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think it means that something like the following should be added:
|
Perfect. I'll be work on this. |
See issue matplotlib#26244 for more information.
Issue matplotlib#26244 for more info.
See the issue matplotlib#26244
Okay, my progress was the following, I wrote a few lines in the file colormaps.py where I create a function called listColormaps() the important thing is that according to the type of colormap it will list the available patterns. Now, I find it useful to declare in a global way the variables of the colormap types that exist, that is to say: Perceptually, Sequential, Sequential2, Cyclic, Qualitative, Miscellaneous. In such a way that if more patterns are developed it will be easier to extend the functionalities. Attached is the code # New function to list the actually colormaps on matplotlib
def listColormaps(category):
# Define a dictionary that maps each category to its corresponding list of colormaps
colormaps_by_category = {
'Perceptually': ['viridis', 'plasma', 'inferno', 'magma', 'cividis'],
'Sequential': ['Greys', 'Purples', 'Blues', 'Greens', 'Oranges', 'Reds',
'YlOrBr', 'YlOrRd', 'OrRd', 'PuRd', 'RdPu', 'BuPu',
'GnBu', 'PuBu', 'YlGnBu', 'PuBuGn', 'BuGn', 'YlGn'],
'Sequential2': ['binary', 'gist_yarg', 'gist_gray', 'gray', 'bone',
'pink', 'spring', 'summer', 'autumn', 'winter', 'cool',
'Wistia', 'hot', 'afmhot', 'gist_heat', 'copper'],
'Diverging': ['PiYG', 'PRGn', 'BrBG', 'PuOr', 'RdGy', 'RdBu', 'RdYlBu',
'RdYlGn', 'Spectral', 'coolwarm', 'bwr', 'seismic'],
'Cyclic': ['twilight', 'twilight_shifted', 'hsv'],
'Qualitative': ['Pastel1', 'Pastel2', 'Paired', 'Accent', 'Dark2',
'Set1', 'Set2', 'Set3', 'tab10', 'tab20', 'tab20b',
'tab20c'],
'Miscellaneous': ['flag', 'prism', 'ocean', 'gist_earth', 'terrain',
'gist_stern', 'gnuplot', 'gnuplot2', 'CMRmap',
'cubehelix', 'brg', 'gist_rainbow', 'rainbow', 'jet',
'turbo', 'nipy_spectral', 'gist_ncar']
}
# Return the list of colormaps for the given category, or an empty list if the category is not found
return colormaps_by_category.get(category, []) |
In https://matplotlib.org/stable/api/cm_api.html#matplotlib.cm.ColormapRegistry it is clearly marked as a subsclass of a
I think it is reasonable to expect users to infer that I think at most we need a note in explain/colors/colormaps.html to the same effect. |
Good first issue - notes for new contributorsThis issue is suited to new contributors because it does not require understanding of the Matplotlib internals. To get started, please see our contributing guide. We do not assign issues. Check the Development section in the sidebar for linked pull requests (PRs). If there are none, feel free to start working on it. If there is an open PR, please collaborate on the work by reviewing it rather than duplicating it in a competing PR. If something is unclear, please reach out on any of our communication channels. |
Flagging this as a good first issue because the solution is add what @oscargus wrote in #26244 (comment) in the locations described in #26244 (comment) |
…t of registered colormaps re: issue matplotlib#26244
…t of registered colormaps re: issue matplotlib#26244
Documentation Link
https://matplotlib.org/devdocs/users/explain/colors/colormaps.html
Problem
Getting a full list of colormaps is documented in the cmap registry call function and far as I can tell nowhere else.
https://github.com/matplotlib/matplotlib/blob/f017315dd5e56c367e43fc7458fd0ed5fd9482a2/lib/matplotlib/cm.py#L100C1-L107C1
Suggested improvement
I think documentation of how to get a full list of registered colormaps should be added to:
The text was updated successfully, but these errors were encountered: