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

Add new color palettes with interactive palette widgets #286

Merged
merged 12 commits into from Sep 21, 2014
Merged

Conversation

@mwaskom
Copy link
Owner

mwaskom commented Sep 9, 2014

This PR has a few things all related to color palettes:

New palette functions:

  • light_palette(): complement to dark_palette but blend from a very light version of the seed color
sns.palplot(sns.light_palette("seagreen", 10))

light_pal

  • diverging_palette(): Given two hues of equal lightness and saturation (chosen in HUSL space), make a diverging palette between them with either a light or
    a dark midpoint.
sns.palplot(sns.diverging_palette(220, 10, n=9))

diverg_pal

New ways to specify custom sequential palettes

  • The dark_, light_, and blend_palette functions have a new input parameter that controls how the color argument is interpreted: in addition to the range of color specs built into matplotlib, this can also be hls or husl for coords in those systems or xkcd for a named color in the xkcd survey database.
sns.palplot(sns.dark_palette("sea", 8, input="xkcd"))

xkcd_pal

Interactive widgets to choose palettes

This is the most exciting part of the PR.

This complementes the choose_cubehelix (now renamed to choose_cubehelix_palette for consistency) function that was in 0.4 to cover most of the custom palette functions: choose_colorbrewer_palette, choose_dark_palette, choose_light_palette, and choose_diverging_palette:

screenshot 2014-09-09 08 30 26

But the really exciting part is that these functions now return either a list of colors or a matplotlib colormap (when as_cmap is True) so they can actually be used in part of a normal workflow to interactively choose a palette and then pass the returned object to seaborn or matplotlib functions:

screenshot 2014-09-09 08 29 20

To do

  • Tests
  • Docstrings
  • Tutorial documentation
  • Release notes
  • Rename choose_cubehelix
@mwaskom mwaskom changed the title Add new color palettes with interactive palette choosers Add new color palettes with interactive palette widgets Sep 9, 2014
@@ -103,6 +105,8 @@ def color_palette(name=None, n_colors=6, desat=None):
palette = hls_palette(n_colors)
elif name == "husl":
palette = husl_palette(n_colors)
elif name.lower() == "jet":
raise ValueError("No.")

This comment has been minimized.

Copy link
@tacaswell

tacaswell Sep 10, 2014

Contributor

This made me laugh.

@mwaskom
Copy link
Owner Author

mwaskom commented Sep 10, 2014

See also matplotlib/matplotlib#3491 for related discussion

@phobson
Copy link
Contributor

phobson commented Sep 10, 2014

so cool 👍

@mwaskom mwaskom force-pushed the more_color_palettes branch from 5e804f5 to 8c4cc78 Sep 13, 2014
@mwaskom mwaskom force-pushed the more_color_palettes branch from 05d5aee to b81b7f8 Sep 15, 2014
mwaskom added a commit that referenced this pull request Sep 21, 2014
Add new color palettes with interactive palette widgets
@mwaskom mwaskom merged commit f43a5ce into master Sep 21, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@mwaskom mwaskom deleted the more_color_palettes branch Sep 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.