8000 [ENH]: Add Universal Color Design categorical palette · Issue #27757 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

[ENH]: Add Universal Color Design categorical palette #27757

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

Closed
mbhall88 opened this issue Feb 7, 2024 · 12 comments
Closed

[ENH]: Add Universal Color Design categorical palette #27757

mbhall88 opened this issue Feb 7, 2024 · 12 comments

Comments

@mbhall88
Copy link
mbhall88 commented Feb 7, 2024

Problem

Hi,

I think the Color Universal Design colorblind-friendly palette would be a great addition to matplotlib.

As mentioned in mwaskom/seaborn#3631 this would make sense to add as a categorical colourmap to matplotlib.

Proposed solution

I have created a repository with some examples of the palette you can take a look at: https://github.com/mbhall88/cud

@ksunden
Copy link
Member
ksunden commented Feb 8, 2024

The term "palette" does not actually map to any specific feature in our API.

The closest ideas are:

If you are seeking to change the default color cycle, there is extensive conversation on the topic in #9460.

If you would simply like to add one (or more, but keep it relatively small, I'd say) entry into the mpl.color_sequences instance by default, I think that would be considered... All current entries into this list are qualitative color maps, so perhaps would do the same... We are generally a little hesitant to add new colormaps, because the more we have the harder it is to know which ones you should use, and it is difficult to change them as they are considered public API.

In general there is a bit of a balancing act here as one of the things that generally makes it easier to differentiate regardless of color perception differences is changes in lightness... however in a color cycle we tend to not want to emphasize any particular values in the cycle and thus having them be the same lightness is desirable, so you only really get to play with hue if you want perceptual uniformity... And then you have to balance having enough colors with having colors that are differentiable. (and different hues have different perceptual lightness with different forms of colorblindness)

@mwaskom
Copy link
mwaskom commented Feb 9, 2024

In general there is a bit of a balancing act here as one of the things that generally makes it easier to differentiate regardless of color perception differences is changes in lightness... however in a color cycle we tend to not want to emphasize any particular values in the cycle and thus having them be the same lightness is desirable

Yeah this is part of why the seaborn colorblind palette modifies the UCD values. While the colors are more universally discriminable, the extreme variation in luminance (especially the very dark black color) tends to alter perceptions of the plots even for people with normal color vision — making the dark black elements appear qualitatively quite different, and strongly emphasizing some of the others (bright yellow, vermillion). That bright yellow also has fairly poor constrast against white.

Always a lot of tradeoffs in data visualization, especially when it come to color!

@mbhall88
Copy link
Author

If you are seeking to change the default color cycle, there is extensive conversation on the topic in #9460.

Oh no, I certainly am not asking to change the default colour cycle.

You all know a lot more than me so sounds like I should just close this as it maybe doesn't suit being in as a colour map option as there is already a lot and the different hues might not be universal enough.

Happy to just leave it as is and leave this closed issue as a reference for anyone else searching for this colourmap

@mwaskom
Copy link
mwaskom commented Feb 14, 2024

IMO this is still worthy of an addition as a qualitative color map in matplotlib!

@mbhall88
Copy link
Author

Okay, well @ksunden do you think it's worthwhile attempting to add this? What is the process for doing that?

@mbhall88 mbhall88 reopened this Feb 14, 2024
@story645
Copy link
Member
story645 commented Feb 14, 2024

Your best bet is opening a PR adding the new colormap - generally our current criteria for new ones are:

  • serves a need not covered by built in maps
  • general purpose (so not used by only one domain)
  • there's an academic paper/industry white paper explaining the colormap & justification for it.
  • Is public domain/not copyrighted.

@mbhall88
Copy link
Author

@QuLogic
Copy link
Member
QuLogic commented Feb 16, 2024

I did find it a bit weird that the page is on a repository about flies, and not some kind of human research page. They do mention creating a "Color Universal Design Organization" (CUDO), but unfortunately, the link is 404. The site does appear to be working, but is almost entirely in Japanese, so I cannot be 100% sure. We did some looking yesterday, and best we could find was this page, but unfortunately, all the images are dead.

We also found a page on the DIC Global website, which appears to be a pigment/paint/chemical manufacturer. In the section titled The Color Universal Design–Recommended Color Set, there appears to be a third edition of the colours. At the end of that section, there is a link to the guidebook in PDF format which appears to contain a fourth edition. There is more guidance in there for 4/5/6 palettes, and also a pastel-looking version.

However, my Japanese is otherwise non-existent, so it would be best to get someone fluent to translate it (the PDF is composed of images, so I cannot copy&paste into translation software.) If we were to add this, it would be best to use the most current edition, but someone does need to untangle what that is (e.g., I don't know if DIC Global is definitive or just their interpretation for their own use.)

@mbhall88
Copy link
Author
mbhall88 commented Feb 16, 2024

Interesting. I assume you saw this also? https://jfly.uni-koeln.de/color/ - this is where I got the colourmap for the github repo I linked at the top (https://github.com/mbhall88/cud)

@jklymak
Copy link
Member
jklymak commented Feb 16, 2024

I'm still confused if you are trying to make a colormap, or a color sequence. As noted by @ksunden, we don't have a "palette" concept. We have colormaps, which are defined in colors.py with help from _cm.py and _listed_cm.py, and stored in a ColormapRegistry, accused by matplotlib.colors.get_cmap, and is used extensively for color mapping.

We also have a ColorSequenceRegistry that is accessed by matplotlib.color_sequences, but I don't see that we have any examples of how you would use that or why.

Finally, we have style sheets that support a sequence of colors. I guess that is the eventual plan for ColorSequenceRegistry, but it is not currently used that way. This cycle of colors (C0, C1...) are probably what you are aiming at. Note we already have tableau10_colorblind: https://matplotlib.org/stable/gallery/style_sheets/style_sheets_reference.html

@QuLogic
Copy link
Member
QuLogic commented Feb 16, 2024

Interesting. I assume you saw this also? https://jfly.uni-koeln.de/color/ - this is where I got the colourmap for the github repo I linked at the top (https://github.com/mbhall88/cud)

I did; that's the article on the repository about flies. It's also dated 2002/2008, while the others are 2013/2018.

@mbhall88
Copy link
Author

Okay, clearly my understanding is pretty low here as I don't really understand the difference between a palette and a colourmap etc.

Again, I think I'll just close this and leave it here as a reference for anyone else. Given there is already tableau_10_colorblind that should be more than sufficient

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

No branches or pull requests

6 participants
0