Last active
April 14, 2022 07:07
-
-
Save nbren12/585e73cb5543568bc83f220f85890870 to your computer and use it in GitHub Desktop.
Colorblind friendly defaults
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://davidmathlogic.com/colorblind/#%23000000-%23E69F00-%2356B4E9-%23009E73-%23F0E442-%230072B2-%23D55E00-%23CC79A7 | |
wong_palette = [ | |
"#000000", | |
"#E69F00", | |
"#56B4E9", | |
"#009E73", | |
"#F0E442", | |
"#0072B2", | |
"#D55E00", | |
"#CC79A7", | |
] | |
# altair | |
import altair | |
def my_theme(): | |
return {"config": {"range": {"category": wong_palette}}} | |
altair.themes.register("my_theme", my_theme) | |
altair.themes.enable("my_theme") | |
# plotly express | |
import plotly.express as px | |
px.defaults.color_discrete_sequence = wong_palette | |
# matplotlib | |
import matplotlib.pyplot as plt | |
from cycler import cycler | |
plt.rcParams["axes.prop_cycle"] = cycler("color", wong_palette) |
Author
nbren12
commented
Dec 14, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment