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

Ability to reduce central 'whiteness' in diverging colormaps #49

Closed
psharda opened this issue Nov 15, 2022 · 4 comments
Closed

Ability to reduce central 'whiteness' in diverging colormaps #49

psharda opened this issue Nov 15, 2022 · 4 comments
Labels
feature request New idea or feature request

Comments

@psharda
Copy link

psharda commented Nov 15, 2022

I would like to use cmasher's beautiful diverging colormaps for plotting purposes. I need a diverging colormap where the color in the centre is 'close to' white but not completely white. The closest equivalent of what I want is the colormap 'coolwarm' in Matplotlib. Just like cmasher has an ability to cut colors from the edges, is it possible to introduce the ability to cut color from the centre? The available diverging colormaps with a white centre are too white for my purpose. Thanks for considering this idea in advance!

@psharda psharda added the feature request New idea or feature request label Nov 15, 2022
@1313e
Copy link
Owner

1313e commented Nov 18, 2022

Hmm, that shouldn't be too hard to make. I can have a look at that.

@psharda
Copy link
Author

psharda commented Nov 18, 2022

Great, thanks! Looking forward to it.

@DanielYang59
Copy link
Contributor

DanielYang59 commented Feb 22, 2024

This is now possible with the combine_cmaps utility. It doesn't directly allow chopping out a part of a colormap, but you could achieve this by taking two sub_cmaps to avoid the central unwanted part, and recombine them, like so:

from cmasher.utils import combine_cmaps, get_sub_cmap, view_cmap

cmap_part_0 = get_sub_cmap("cmr.fusion", 0, 0.45)
cmap_part_1 = get_sub_cmap("cmr.fusion", 0.55, 1)

new_cmap = combine_cmaps(cmap_part_0, cmap_part_1)
view_cmap(new_cmap)

In this case I removed the central 10% but apparently you would need some further tweaking.

Before:
before

After:
after

@neutrinoceros
Copy link
Collaborator

Thanks @DanielYang59 for your reply ! Indeed it seems that we now have API to support this use case so I believe this can be closed as solved in cmasher 1.8.0. Feel free to ping me if I'm understanding this wrong and the issue should be re-opened !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New idea or feature request
Projects
None yet
Development

No branches or pull requests

4 participants