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

Define Palettes and Cycles from backend specific colormaps/palettes #1605

Merged
merged 1 commit into from Jun 25, 2017

Conversation

Projects
None yet
2 participants
@philippjfr
Member

philippjfr commented Jun 25, 2017

Since we no longer import the matplotlib backend the list of Palettes are only populated if that particular backend is imported. This PR does several things:

  1. A Cycle can be instantiated with a key or a list of values without having to specify the parameter name, i.e. before you had to do Cycle(values=['red', 'green', 'blue']) or Cycle(key='default_colors') now you can do Cycle(['red', 'green', 'blue']) or Cycle('default_colors').
  2. We now define a number of default Cycles for both matplotlib and bokeh, since there is at least some overlap we can always rely on things like Set1-3, Dark2 and a few others to be there.
  3. We also define default Palettes in bokeh.

The behavior of Palette has always been a bit odd and we should probably discuss/address that for 2.0, since it samples the provided function like a colormap and therefore does not cycle. I think that distinction still makes sense as cycling is what Cycle is for but we need to document this at some point. For the time being this is 1) completely backward compatible, 2) allows using categorical colormaps as Cycles and 3) ensures that at least a subset of categorical colormaps/palettes are available for both matplotlib and bokeh.

@@ -106,6 +107,17 @@
Cycle.default_cycles['default_colors'] = ['#30a2da', '#fc4f30', '#e5ae38',
'#6d904f', '#8b8b8b']
# Define Palettes and Cycles from bokeh palettees

This comment has been minimized.

@jlstevens

jlstevens Jun 25, 2017

Member

Typo: palettees

This comment has been minimized.

@philippjfr

philippjfr Jun 25, 2017

Member

Palettees?

This comment has been minimized.

@philippjfr

philippjfr Jun 25, 2017

Member

Ah I'm blind.

@@ -106,6 +107,17 @@
Cycle.default_cycles['default_colors'] = ['#30a2da', '#fc4f30', '#e5ae38',
'#6d904f', '#8b8b8b']
# Define Palettes and Cycles from bokeh palettees
def colormap_generator(palette):

This comment has been minimized.

@jlstevens

jlstevens Jun 25, 2017

Member

Any reason not to just return a lambda?

@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 25, 2017

@philippjfr Other than the two comments I made, looks good.

I would like to merge this ASAP as this would help me for some of the examples I am currently working on...

@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 25, 2017

I think that distinction still makes sense as cycling is what Cycle is for but we need to document this at some point.

Agreed. I think it might be worth filing an issue to discuss palettes but I don't think that discussion should hold up this PR.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 25, 2017

Looks good. Merge when the tests pass?

@philippjfr

This comment has been minimized.

Member

philippjfr commented Jun 25, 2017

Yes, ready, here's the set of categorical Cycles that are available for both matplotlib and bokeh:

{u'Accent',
 u'Dark2',
 u'Paired',
 u'Pastel1',
 u'Pastel2',
 u'Set1',
 u'Set2',
 u'Set3'}
@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 25, 2017

Wonder where we should record that information about what is consistent and available...

@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 25, 2017

Maybe colormaps/palettes should have a user guide?

@philippjfr

This comment has been minimized.

Member

philippjfr commented Jun 25, 2017

Maybe colormaps/palettes should have a user guide?

Seems sensible, or fold it into a more general user guide about plotting in addition to the backend specific guides we already have planned.

@jlstevens

This comment has been minimized.

Member

jlstevens commented Jun 25, 2017

Tests are green. Merging.

@jlstevens jlstevens merged commit d57bfb6 into master Jun 25, 2017

4 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.003%) to 79.806%
Details
s3-reference-data-cache Test data is cached.
Details

@philippjfr philippjfr deleted the palettes_cycles branch Jul 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment