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

Improvements and changes to defaults in heatmap #1184

Merged
merged 24 commits into from Jul 1, 2017
Merged

Conversation

@mwaskom
Copy link
Owner

mwaskom commented May 22, 2017

A few changes are wrapped up in here:

  • Changed the behavior of heatmap (and by extension clustermap) when plotting divergent dataesets (i.e. when the center parameter is used). Instead of extending the lower and upper limits of the colormap to be symettrical around the center value, the colormap is modified so that its middle color corresponds to center. This means that the full range of the colormap will not be used (unless the data or specified vmin and vmax are symettric), but the upper and lower limits of the colorbar will correspond to the range of the data. Here is an example:
sns.heatmap(corrmat, square=True, center=0, cmap="RdBu_r", ...)

image

Note how the colorbar stops at -.4 and does not include dark blue values. The recentering also respects custom colormap limits:

sns.heatmap(corrmat, square=True, center=0, cmap="RdBu_r", vmin=-.15, vmax=.6, ...)

image

  • Removed automatic detection of diverging data in heatmap (and by extension clustermap). If you want the colormap to be treated as diverging (see above), it is now necessary to specify the center value. When no colormap is specified, specifying center will still change the default to be one that is more appropriate for displaying diverging data.

  • Added four new colormaps, created with viscm for perceptual uniformity. There are two new sequential colormaps ("rocket" and "mako") and two new diverging colormaps ("icefire" and "vlag"). The colormaps and reversed ("_r") variants are automatically registered in matplotlib on seaborn import. They look like this:

colormaps

  • Changed the default heatmap colormaps to "rocket" and "icefire" for sequential and diverging data, respectively.

  • Changed the default tick labels in heatmap to "auto", which estimates how many ticks can be labeled without overlap.

  • Changed the clustermap API examples to use the brain networks dataset which is a little bit closer to the kind of dataset you would be using it with.

Closes #1169
Closes #1192

@mwaskom mwaskom force-pushed the recenter_heatmap_colorscale branch 2 times, most recently from 005fb5f to 160b78c May 24, 2017
@mwaskom mwaskom changed the title WIP: Improve/simplify diverging colormaps in matrix plots WIP: Improvements and changes to defaults in heatmap Jun 21, 2017
@mwaskom
Copy link
Owner Author

mwaskom commented Jun 21, 2017

A possible TODO: in the reversed versions of the new sequential colormaps, I don't like how it tops out in a dark black and prefer a "short" version of the colormap that does not include the darkest ~40 values:

image

There's not currently a convention for describing such colormaps (akin to "_r"), nor is there a mechanism for easily cropping a colormap. One idea would be to monkey patch matplotlib's get_cmap function to allow a spec like "rocket_r_:10:-40", which would slice out the colors in the lut and return a new colormap (could also do floats). Possibly outside of the scope of this PR.

This point is also relevant for using these wide-luminance range colormaps to map points/lines. Regrettably, matplotlib chose not to distinguish between a default image colormap and glyph colormap, even though the optimal properties of the two are clearly different.

@mwaskom
Copy link
Owner Author

mwaskom commented Jun 26, 2017

This PR should maybe include handling of #1192

@mwaskom mwaskom force-pushed the recenter_heatmap_colorscale branch from e3327cd to 98e248a Jun 28, 2017
@mwaskom mwaskom force-pushed the recenter_heatmap_colorscale branch from 9ac7a12 to 5c864df Jul 1, 2017
@mwaskom mwaskom changed the title WIP: Improvements and changes to defaults in heatmap Improvements and changes to defaults in heatmap Jul 1, 2017
@mwaskom mwaskom merged commit 37dd93e into master Jul 1, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@mwaskom mwaskom deleted the recenter_heatmap_colorscale branch Jul 1, 2017
@mmagnuski
Copy link

mmagnuski commented Jul 1, 2017

❤️ 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.