Skip to content

Conversation

@MrZaurik
Copy link

@MrZaurik MrZaurik commented Jul 19, 2023

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.

# 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, [])

@MrZaurik MrZaurik closed this Jul 19, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants