What is the output format of
sns.color_palette('Reds', 5)?
How can I convert it to Hex numbers?
Running the above command gives you the Output of:
[(0.99358708227381987, 0.83234141714432663, 0.76249136363758763), (0.98823529481887817, 0.62614381313323975, 0.50849674145380652), (0.98357554884517895, 0.4127950837799147, 0.28835064675293715), (0.89019608497619629, 0.18562091638644537, 0.15294117977221808), (0.69439448188332953, 0.070034602810354785, 0.092318341048324815)]
How can I convert that to an output like below:
["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71", "#43A16F"]
Even better (assuming seaborn >= 0.6):
import seaborn as sns
pal = sns.color_palette('Reds', 5)
pal.as_hex()
['#fdd4c2', '#fca082', '#fb694a', '#e32f27', '#b11218']
Matplotlib has a rgb2hex
function:
rgb_colors = sns.color_palette('Reds', 5))
hex_colors = list(map(mpl.colors.rgb2hex, rgb_colors)
Results in:
['#fdd4c2', '#fca082', '#fb694a', '#e32f27', '#b11218']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With