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

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

Merged
merged 1 commit into from Jun 25, 2017

Conversation

philippjfr
Copy link
Member

@philippjfr 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: palettees

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Palettees?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to just return a lambda?

@jlstevens
Copy link
Contributor

@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
Copy link
Contributor

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
Copy link
Contributor

Looks good. Merge when the tests pass?

@philippjfr
Copy link
Member Author

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
Copy link
Contributor

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

@jlstevens
Copy link
Contributor

Maybe colormaps/palettes should have a user guide?

@philippjfr
Copy link
Member Author

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
Copy link
Contributor

Tests are green. Merging.

@jlstevens jlstevens merged commit d57bfb6 into master Jun 25, 2017
@philippjfr philippjfr deleted the palettes_cycles branch July 31, 2017 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants