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

Colour map manipulation tools #1

Closed
MBravoS opened this issue Jul 6, 2021 · 4 comments
Closed

Colour map manipulation tools #1

MBravoS opened this issue Jul 6, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@MBravoS
Copy link
Owner

MBravoS commented Jul 6, 2021

With @AstroRobin we have discussed before including some of the functions included in cmocean, and while crop and crop_by_percent are straightforward to add (and I'm hoping to add soon), lighten is not. They change the alpha to increase the lightness of the colour maps, which has three issues:

  • It only works for light backgrounds, as matplotlib performs alpha compositing with it. Using a dark background will actually make the colour map appear darker.
  • It will blend with anything else that has alpha<1.
  • The alpha compositing is made in CIE XYZ (a RGB colour space), which means that linear colour maps become strongly non-linear.
    I need to think more about this, but possibly doing the compositing in any La*b* colour space (like CAM02-UCS) could fix this.
@MBravoS MBravoS added the enhancement New feature or request label Jul 6, 2021
@MBravoS MBravoS self-assigned this Jul 6, 2021
@MBravoS
Copy link
Owner Author

MBravoS commented Jul 8, 2021

I just noticed that there are some quirks to the functions used to crop the colour maps, as implemented in cmocean. They seem particularly targeted to diverging colour maps, as for example using crop_by_percentage to crop less than half of the colour map above or below the mid point throws an error. Will need to think how to deal with this.

Regarding the lighten function, my idea of making the alpha compositing in any La*b* space can lead to issues, as that can lead to colours outside perceptually-based colour spaces like CIELab or CAM02-UCS. At this point I have no other idea other than to add a new set of "pastel" colour maps. What do you think @AstroRobin?

@AstroRobin
Copy link
Collaborator

Given there does not seem to be a feasible way to systematically 'lighten' colourmaps without keeping the linearity reasonable, I think your idea of a pastel version for certain colourmaps is a good idea. I suppose this will only apply to monochromatic and possibly bichromatic(?) colourmaps only. We will, of course, need to think about how we will name these without the naming convention being too verbose.

@MBravoS
Copy link
Owner Author

MBravoS commented Aug 13, 2021

I ended not adopting anything from cmocean, as I wasn't entirely sure about the motivation for their design choices. I have created three new functions (crop, merge and stitch) that are parte of a new submodule (scicm.tools) in the devel_matias branch. I'll have another go at the examples for the README before pushing to the master branch, but in the meantime could you test the functions @AstroRobin? Just to be sure that I did not leave any obvious bugs/issues hanging around.

@MBravoS
Copy link
Owner Author

MBravoS commented Aug 18, 2021

Added in version 0.5.0. Following @AstroRobin's suggestion I simplified the examples.

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

No branches or pull requests

2 participants