I'm trying to use Seaborn to present a 1d dataframe as a horizontal bar graph. I would like to shade the bars using the coolwarm palette to reflect their magnitude and direction.
In other words, I'm hoping to generate something like the second example shown here (this is from the Seaborn site), but I want to orient it horizontally:
I've succeeded in turning the graph sideways, but I can't seem to make the palette apply along the horizontal axis as well. My code:
import pandas as pd, seaborn as sns
sns.set()
df = pd.DataFrame([7,-5,-2,1.5,-3],
index=['question 1','question 2','question 3','question 4','question 5'],
columns=['t'])
sns.barplot(data= df,
x= 't',
y= df.index,
palette= 'coolwarm')
The output:
I'd like it to go from blue to red as you move from left to right (instead of top to bottom).