tsipkens / cmap

Perceptually uniform colormaps for MATLAB, compiled from multiple sources.
44 stars 13 forks source link

Colorbrewer colormap orientations are inconsistent #4

Open briochemc opened 2 years ago

briochemc commented 2 years ago

Just noticed that out of the diverging colorbrewer colormaps listed here

Screen Shot 2022-03-31 at 3 34 42 pm

Only the first and last ones are oriented in the same way that https://colorbrewer2.org/#type=diverging is. In other words rdylgn, piyg, and prgn should be reversed to match the original colormaps. Note that I have not checked other colormaps!

I think colorbrewer chose these orientations because we traditionally expect red-ish colors to represent the most positive values (i.e., at the top/right/end of the colormap).


That being said, colorbrewer's naming convention itself is not consistent, e.g., RdBu starts with blue (at the bottom) while PuOr starts with ~orange~ purple (edited)...

Screen Shot 2022-03-31 at 3 48 20 pm Screen Shot 2022-03-31 at 3 48 13 pm

So maybe it is worth correcting colorbrewer's inconsistency here and only having names that match the color order? I.e., RdBu would go from red to blue. An ideal solution is probably to also allow for BuRd in this case, which would go blue to red. What do you think?

tsipkens commented 2 years ago

Good catch. I have opted instead to match the diverging colormap order to their names rather than the original orders. This required reversing of the RdBu colormap. The colormaps can be easily reversed using MATLAB's built-in flipud(...) function.

Fixed in the master branch.

briochemc commented 2 years ago

The colormaps can be easily reversed using MATLAB's built-in flipud(...)

I know! I meant we could easily add in convenience functions that go, e.g.,

function cm = pubu(n, opt_interp)
    cm = flipup(bupu(n, opt_interp))
end

Given your decision to opt for "the colormap follows the name order", this would be nice IMHO :)

tsipkens commented 2 years ago

Reopened while I consider this.