Created
July 11, 2023 03:06
-
-
Save JGreenlee/b03534aad580cbfd6649729e61b0a376 to your computer and use it in GitHub Desktop.
Extract Seaborn Color Palettes to JSON File
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
{ | |
"deep": { | |
"blue": "#4c72b0", | |
"orange": "#dd8452", | |
"green": "#55a868", | |
"red": "#c44e52", | |
"purple": "#8172b3", | |
"brown": "#937860", | |
"pink": "#da8bc3", | |
"gray": "#8c8c8c", | |
"olive": "#ccb974", | |
"cyan": "#64b5cd" | |
}, | |
"muted": { | |
"blue": "#4878d0", | |
"orange": "#ee854a", | |
"green": "#6acc64", | |
"red": "#d65f5f", | |
"purple": "#956cb4", | |
"brown": "#8c613c", | |
"pink": "#dc7ec0", | |
"gray": "#797979", | |
"olive": "#d5bb67", | |
"cyan": "#82c6e2" | |
}, | |
"pastel": { | |
"blue": "#a1c9f4", | |
"orange": "#ffb482", | |
"green": "#8de5a1", | |
"red": "#ff9f9b", | |
"purple": "#d0bbff", | |
"brown": "#debb9b", | |
"pink": "#fab0e4", | |
"gray": "#cfcfcf", | |
"olive": "#fffea3", | |
"cyan": "#b9f2f0" | |
}, | |
"bright": { | |
"blue": "#023eff", | |
"orange": "#ff7c00", | |
"green": "#1ac938", | |
"red": "#e8000b", | |
"purple": "#8b2be2", | |
"brown": "#9f4800", | |
"pink": "#f14cc1", | |
"gray": "#a3a3a3", | |
"olive": "#ffc400", | |
"cyan": "#00d7ff" | |
}, | |
"dark": { | |
"blue": "#001c7f", | |
"orange": "#b1400d", | |
"green": "#12711c", | |
"red": "#8c0800", | |
"purple": "#591e71", | |
"brown": "#592f0d", | |
"pink": "#a23582", | |
"gray": "#3c3c3c", | |
"olive": "#b8850a", | |
"cyan": "#006374" | |
}, | |
"colorblind": { | |
"blue": "#0173b2", | |
"orange": "#de8f05", | |
"green": "#029e73", | |
"red": "#d55e00", | |
"purple": "#cc78bc", | |
"brown": "#ca9161", | |
"pink": "#fbafe4", | |
"gray": "#949494", | |
"olive": "#ece133", | |
"cyan": "#56b4e9" | |
} | |
} |
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
import seaborn as sns | |
import json | |
colors = ['blue', 'orange', 'green', 'red', 'purple', 'brown', 'pink', 'gray', 'olive', 'cyan'] | |
palettes_dict = {} | |
def add_palette(palette_name): | |
pal = sns.color_palette(palette_name, 10).as_hex() | |
palettes_dict[palette_name] = { colors[i]: pal[i] for i in range(10) } | |
add_palette('deep') | |
add_palette('muted') | |
add_palette('pastel') | |
add_palette('bright') | |
add_palette('dark') | |
add_palette('colorblind') | |
with open('output_palettes.json', 'w') as f: | |
json.dump(palettes_dict, f, indent=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment