I'm reading and testing the seaborn
palette tutorial.
I would be interested in a dark diverging palette based on a predefined matplotlib
colormap. Is that possible? (Does that even make sense in all cases?)
As I actually only want 3 colours, "black" being the middle one, I can extract the first and last of a palette as follows:
import seaborn as sns
left = sns.color_palette("BrBG")[0]
right = sns.color_palette("BrBG")[-1]
sns.palplot([left, "black", right])
I see that if I increase the number of elements in the source palette, I can obtain darker colours as left and right:
left = sns.color_palette("BrBG", 12)[0]
right = sns.color_palette("BrBG", 12)[-1]
sns.palplot([left, "black", right])
I'm wondering how far dark the left and right colour can go if I increase the number of elements. I suppose they don't end up being black, otherwise the two extremes would become impossible to distinguish.
Is it possible to extract these "extreme" colours directly from the corresponding matplotlib
colormap?
I can also go towards lighter colours asking for less elements in the palette than the default (which is 6). Asking for 2 elements results in something too light for my taste:
left = sns.color_palette("BrBG", 2)[0]
right = sns.color_palette("BrBG", 2)[-1]
sns.palplot([left, "black", right])
Anyway, this approach is not very "clean", and the extremes of a colormap are not necessarily a good choice. Besides, a generalization may be useful: How to create a dark diverging palette with more than 3 colours, based on a predefined colormap?
The above mentioned tutorial says that the function to create custom diverging palettes results in something well balanced and gives the following example:
sns.palplot(sns.diverging_palette(255, 133, l=60, n=7, center="dark")
I guess my question amounts to the following: