jxn
jxn

Reputation: 8055

seaborn horizontal bar plot not showing plot

I can plot a normal bar plot with searborn, but when i specify orient = 'h' nothing shows up in my plot.

df = pd.DataFrame(['A','A','A','B','B','C'],columns = ['letters'])
data =df.letters.value_counts()
sns.barplot(x = data.index, y = data)

enter image description here

With orient:

enter image description here

Upvotes: 0

Views: 3698

Answers (1)

Oleg Medvedyev
Oleg Medvedyev

Reputation: 1594

You have to swap x and y when you change orientation.

df = pd.DataFrame(['A','A','A','B','B','C'],columns = ['letters'])
data =df.letters.value_counts()
sns.barplot(y = data.index, x = data, orient='h')

enter image description here

Upvotes: 6

Related Questions