Skip to content
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

Add a getAvailableNamedPalettes function. #741

Merged
merged 2 commits into from
Dec 17, 2021
Merged

Conversation

manthey
Copy link
Member

@manthey manthey commented Dec 16, 2021

Closes #731.

@manthey manthey requested a review from banesullivan December 16, 2021 22:02
@manthey
Copy link
Member Author

manthey commented Dec 16, 2021

There are a lot of named palettes. With palettable and matplotlib, I get 3380 named palettes excluding individual colors and 4541 including them.

@banesullivan
Copy link
Contributor

banesullivan commented Dec 16, 2021

I get 3380 named palettes excluding individual colors and 4541 including them.

ooof. that's a lot. Too many if trying to send that over to a drop down menu in a UI

Could we separate them into a dictionary? E.g,

{
'matplotlib': ['...', ...],
'palettable': ['...', ...],
'colors': ['...', ...],
...
}

@manthey
Copy link
Member Author

manthey commented Dec 17, 2021

A large number of the variations come from (a) palettable having distinct names for each variant with a different number of points in the lookup table (e.g., cartocolors.diverging.Earth_2, cartocolors.diverging.Earth_3, cartocolors.diverging.Earth_4, cartocolors.diverging.Earth_5, cartocolors.diverging.Earth_6, cartocolors.diverging.Earth_7), and most palettes having an _r reversed variant (so cartocolors.diverging.Earth_2 and cartocolors.diverging.Earth_2_r). If we exclude the lower count palettes, the reversed palettes, and the colors, the count drops to a mere 212 palettes.

I think a better choice might be to add a reduced option to the function that would exclude the reversed palettes and the lower numbered palettes, then getAvailableNamedPalettes(includeColors=False, reduced=True) would return a much smaller set (212).

@manthey
Copy link
Member Author

manthey commented Dec 17, 2021

I pushed a change adding the reduced option. If you think this is sufficient, please approve the PR. If you still think return a dictionary of results makes sense, we probably need to discuss the granularity of it. For instance, should PIL colors and matplotlib colors be separate entries? Should we subset the palettable entries in any manner?

@manthey
Copy link
Member Author

manthey commented Dec 17, 2021

Lastly, in the reduced set of palettes, there are some function duplicates: lightbartlein.diverging.BlueGray_8 is the same as lightbartlein.diverging.BlueGrey_8; matplotlib shares 9 palettes with palettable such as Pastel2 and colorbrewer.qualitative.Pastel2_8. Short of instantiating the palettes, duplicates are somewhat hard to detect (and then you have to pick a preferred name).

Copy link
Contributor

@banesullivan banesullivan left a comment

Choose a reason for hiding this comment

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

I think shortening the way you did is a good implementation and this PR is good to merge.

Downstream, we may just create this list ourselves in RGD. I'm not huge on palettable and I think we'll just stick with MPL's full set (along with cmocean's as well) as the reversed maps are very useful

@manthey manthey merged commit d68f394 into master Dec 17, 2021
@manthey manthey deleted the enumerate-palettes branch December 17, 2021 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add getAvailableNamedPalettes() utility function
2 participants