ayvahb
ayvahb

Reputation: 11

How to use seaborn.barplot() for negative output?

Suppose i have a dataframe as follows
: Sex = [male, female, female, male, male] for which result = [0,1,1,0,1]

Now sns.barplot(x='Sex', y = 'result' ,data=dataframe) would plot a barplot only for result==1. What if I want the plot for result==0 using the same sns.barplot function?

Upvotes: 0

Views: 428

Answers (1)

Josh Friedlander
Josh Friedlander

Reputation: 11657

You can add a reversed column:

df['new'] = (~df.result.astype(bool)).astype(int)

and then

sns.barplot(x='new', y = 'result' ,data=df)

Upvotes: 1

Related Questions