python - How to fill matplotlib bars with a gradient? -


i interested in filling matplotlib/seaborn bars of barplot different gradients done here (not matplotlib far understood): enter image description here

i have checked related topic pyplot: vertical gradient fill under curve?.

is possible via gr-framework: enter image description here or there alternative strategies?

i using seaborn barplot palette option. imagine have simple dataframe 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 like:

enter image description here

then can play palette option , colormap adding gradient according data like:

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

obtaining:

enter image description here

hope helps.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -