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

figrecipes should use palettable colors #232

Closed
computron opened this issue May 23, 2018 · 11 comments · Fixed by #634
Closed

figrecipes should use palettable colors #232

computron opened this issue May 23, 2018 · 11 comments · Fixed by #634

Comments

@computron
Copy link
Contributor

https://jiffyclub.github.io/palettable/

For example, pymatgen DOSPlotter uses this to set color libraries

See also seaborn color palettes:

http://seaborn.pydata.org/tutorial/color_palettes.html

@ardunn
Copy link
Contributor

ardunn commented May 23, 2018

I agree. The colormaps seem to be intended for matplotlib but it doesn't look like there is any reason they wouldn't work with Plotly ... crosses fingers

@ardunn
Copy link
Contributor

ardunn commented Jun 8, 2018

Upon actually trying this, Paletteable and FigRecipes often really don't play nice together. Mostly because converting matplotlib color maps into Plotly-capable format doesn't work outside of the few examples Plotly provides. Perhaps we could choose one of the better Plotly colormaps to be the FigRecipes default?

@ardunn
Copy link
Contributor

ardunn commented Jun 8, 2018

@albalu do we have an example of a custom (ie, non-Plotly) colorscale (a list) being used in figrecipes?

@albalu
Copy link
Contributor

albalu commented Jun 8, 2018

No we always used one of the pre-defined ones.

@ardunn
Copy link
Contributor

ardunn commented Jun 12, 2018

I think for this a good option here to define a utility function that, given a string representing a Palettable colormap, and a number n of colors to return, returns a list of n "equally spaced" hex colors. Then you can just plug that list into whatever plotlyfig args you want. If no colors are specified by the user, it uses a good default one.

@computron
Copy link
Contributor Author

You might want to consult with @mkhorton , he is good with colors

@mkhorton
Copy link
Contributor

If you want n colors from a qualitative color map, you can do that in Palettable e.g. via:

from palettable.colorbrewer.qualitative import Set1_9
colors = Set1_9.colors  # a list of length 9

It's tricky to get large palettes that are also color-blind safe however, e.g. see http://mkweb.bcgsc.ca/colorblind/ for some examples of 7 color palettes and 12 color palettes. I don't really think any plot with more than ~7 categorical/qualitative colors will ever look that great though.

given a Paletteable string and a number n of colors to return, returns a list of n "equally spaced" hex colors

This is easy enough in Palettable, the .mpl_colormap property will return a matplotlib cmap, which then takes values in 0–255 and returns a color, but I wouldn't advise doing this for the above reasons.

But this is just for qualitative/categorical colors. If you need a quantitative, just use viridis courtesy of BIDS :)

@ardunn
Copy link
Contributor

ardunn commented Jun 12, 2018

@mkhorton Awesome! Thanks

@albalu I think we need to specify exactly what the colorscale and colors args mean, otherwise this is gonna get very confusing.

@computron
Copy link
Contributor Author

Btw I sometimes use the app "Color Oracle" to get a sense of how a certain color scheme will work (or not work) for color blindness. I'd rate it as something to not prioritize for default color scheme but to have an option to use color blind safe colors

Btw that web page @mkhorton sent out makes me wonder how many traffic accidents are caused by a poor color choice for traffic lights ...

@mkhorton
Copy link
Contributor

https://link.springer.com/chapter/10.1007/978-94-011-5408-6_54

xScope is a really nice app for simulating color blindness too, though I don't have a copy of the latest version sadly

@computron
Copy link
Contributor Author

I think @utf did a good job of colors on the various codes like "sumo", etc. Might be worth it to just have a discussion w/him for the Figrecipes overall graphic design - colors, fonts, font sizes, etc.

@ardunn ardunn added the ugrads label Dec 11, 2018
@ardunn ardunn removed the ugrads label Oct 2, 2019
@ardunn ardunn mentioned this issue Jun 5, 2021
14 tasks
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 a pull request may close this issue.

4 participants