seaborn

Barplot

Barplot with Gradient

Imagine you have a simple dataframe to plot on a barplot like:

df = pd.DataFrame({'a':[1,2,3,4,5], 'b':[10,5,2,4,5]})

using seaborn:

sns.barplot(df['a'], df['b'], palette='Blues_d')

you can obtain something like:

enter image description here

then you can also play with the palette option and colormap adding a gradient according to some data like:

sns.barplot(df['a'], df['b'], palette=cm.Blues(df['b']*10)

obtaining:

enter image description here


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow