matplotlib / cmocean

Colormap setup for standardizing commonly-plotting oceanographic variables.
MIT License
230 stars 52 forks source link

Add inverting functionality? #105

Closed andrew-s28 closed 6 months ago

andrew-s28 commented 8 months ago

I am hoping to get some thoughts on adding functionality for cmocean colormaps with inverted lightness. Here is an example of what this looks like: image

This functionality is included in the MATLAB cmocean toolbox and some of my collaborators have made good use of it. A specific use case cited in the MATLAB example is using diverging colormaps on light backgrounds.

I see three ways this could be added:

  1. Include _i or _inverted colormaps in the cm.py file for direct access by users.
  2. Include an invert_lightness function in the tools.py file.
  3. Allow negative alpha values in the cmocean.tools.lighten to be interpreted as inverting lightness

One issue is that the solution I have for inverting lightness requires an additional dependency, colorspacious. Although this is already a dependency for the "cmocean[plots]" install, so perhaps not a huge leap.

kthyng commented 8 months ago

@andrew-s28 I didn't know is an option in the Matlab toolbox! Cool! Yeah this would be useful. Any chance you can start on a PR?

andrew-s28 commented 8 months ago

I would be happy to. I should be able to get something together for a PR in the next few days. Thanks for your consideration!

kthyng commented 8 months ago

Sounds great @andrew-s28! Let me know if you have questions along the way.