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

Replaced now-deprecated interpolate() and colorize() with shade(). #214

Merged
merged 5 commits into from
Aug 15, 2016

Conversation

jbednar
Copy link
Member

@jbednar jbednar commented Aug 12, 2016

Various people have found the names interpolate() and colorize() confusing, including me. Both of them could be called "colorize" in some sense, since both of them involve choosing a pixel color for each value in an aggregate array, and it's not clear to users why there are different functions for the two cases. To avoid confusion with the existing function colorize(), it seems better to choose a new name for a combined function, and shade() seems fitting given the name of this library and by analogy with 3D rendering/shading pipelines (where shading is the last step, as here).

The initial commit also weakens checking of the color_key required for categorical aggregates. It now allows passing a long list of colors, to avoid having to pick precisely as many colors as categorical fields. I'll now make a list of suitable distinguishable colors to use as a default, so that people can easily visualize their aggregates using just "shade(agg)" regardless of whether the agg is 2D or 3D (categorical). There has already been a good bit of work on making nice lists of distinguishable colors, but what we need here is a list of distinguishable hues, and all the lists I've seen with more than 12 or so are using value (lightness or darkness) to help distinguish the colors, which we can't do here because we are using value to indicate the underlying data value (e.g. counts, in the census race example). So making a good list of hues isn't as simple as one might think, but it's definitely better to do it once as a default than to force every user to pick such a list themselves!

@jbednar
Copy link
Member Author

jbednar commented Aug 12, 2016

The corresponding notebooks also need to be updated to use shade(), but I haven't committed that yet to make it simpler to test backwards compatibility.

@jbednar
Copy link
Member Author

jbednar commented Aug 13, 2016

To get a good default categorical color key, it looks like we can use Bokeh's Set1_9, Set2_8, and Set3_12 concatenated together, with some colors removed from sets 2 and 3. These color sets originally came from Cynthia Brewer, and are designed to be distinguishable within each set, but the sets are also mostly distinguishable from each other due to saturation differences. The result is 22 different colors that are reasonably well distinguishable on both white and black backgrounds, and tolerate differences in staturation (for white backgrounds) or value (for black):

image

image

In each of these images, the first colors used will be in the bottom left, increasing left to right and bottom to top, so that a plot with up to 9 colors will use the highly saturated colors from set1, with the other colors used for increasing numbers of categories. On their own, these colors can be distinguished when in large enough isolated patches as above, but note that mixing between these colors can create serious ambiguity. E.g. the red and yellow categories overlapping create a nice orange, as expected, making locations with points from both the yellow and red categories ambiguous:

image

image

In practice, there is no way around such mixing being ambiguous for more than 3 categories, so it's still worth choosing colors specifically to reduce that probability for a given dataset.

The new colors seem to work fine on the NYC census data:

image

image

So I'll go with them for now.

@jbednar
Copy link
Member Author

jbednar commented Aug 13, 2016

Should be ready to merge now, pending the outcome of the tests.

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

Successfully merging this pull request may close these issues.

1 participant