[Matplotlib-devel] [rfc] a better interchange format for colormaps

Eric Firing efiring at hawaii.edu
Wed Apr 20 22:32:37 EDT 2016


On 2016/04/20 1:22 PM, Nathaniel Smith wrote:
> Hi matplotters,
>
> We've been working on improving our tool for building custom
> viridis-like colormaps (e.g. adding support for diverging colormaps),
> and one of the things that we got frustrated by is how there's no
> compelling way to save and distribute the resulting colormaps so that
> people can actually use them. So, I wrote up a little spec to
> standardize a way of storing and distributing colormaps in JSON, with
> the hope that we can convince everyone to implement this and stop
> writing silly little conversion scripts all the time.
>
> The v0.1 draft is here:
>      https://github.com/njsmith/json-cm/blob/master/json-cm-spec.md
>
> Any comments? There are always a lot of fiddly details to get right in
> this kind of thing -- I made a bunch of guesses about what kind of
> stuff is important and how to represent it, but it can only benefit
> from review from different perspectives. I would equally love to get
> nitpicky critiques and high-level queries.
>
> Thanks!
> -n
>

Nathaniel,

I like the idea.

Minor and tentative suggestion: add a key to specify the number of 
colors.  Yes, it can be calculated from the length of the "colors" 
string, but I have a hunch the convenience of having it immediately 
available (even grep-able) would be worth the slight redundancy.

Although matplotlib's colormap support was originally designed by John 
Hunter around his LinearSegmentedColormap scheme, that method for 
defining and recording a colormap has always been baffling to most 
people--and the end result is a simple lookup table anyway.  Therefore I 
favor moving to the direct specification of the evenly-spaced 
fine-grained color list (suitable for matplotlib's ListedColormap) as in 
your proposal here.

Eric


More information about the Matplotlib-devel mailing list