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

Chris Barker chris.barker at noaa.gov
Thu Apr 21 15:23:40 EDT 2016


Great idea!

AS it happens, we're messing with colormaps ourselves here, and indeed to
need to have consistent ones across browser-JS and python -- so great
timing!

I'm not so sure about the encoding of the colors -- I read the
justification (nicely written), but I still think file size is pretty much
a non-issue -- these are not going to be gigabytes no matter how you slice
it. and the compressed file sizes are definitely close enough in size to
make no difference. So I would much prefer:

[ [r, g, b], [r,g,b], ....]

However, maybe that's because I still can't wrap my head easily around hex
:-)

I think compatibility with D3 per se should be a minor influence, but if
Javascript itself "likes" to use hex colors and could more easily deal with
this, then I guess that might be a driver (or do I think that because I'm a
pythonista that could easily write the conversion code in Python than JS
...)

Also for discrete colormaps, might there be a use case for transparency?
i.e. RGBA ? In which case, the encoding should be able to handle  either
three or four channels per color with no ambiguity. Would that be two hex
values per color for a 32 bit color (then you have to have a clean
endianness, yes?) or commas or something separating the colors.

As for specifying the number of colors somewhere else, I agree that that's
just a recipe for inconsistency with no gain -- is anyone going to have to
write a parser where they have to alocate teh memory ahead of time???

-CHB


On Wed, Apr 20, 2016 at 4:22 PM, Nathaniel Smith <njs at pobox.com> 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 J. Smith -- https://vorpus.org
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel
>



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20160421/0098746b/attachment.html>


More information about the Matplotlib-devel mailing list