chinmay
chinmay

Reputation: 3

Seaborn factorplot

I am trying to create a factor plot but I am not able to change the kind of it from point to bar. How do we do that?

The codes used are

 import numpy as np
 import matplotlib.pyplot as plt
 import seaborn as sns
 %matplotlib inline
 sns.catplot('Sex',kind="bar",data=titanic_df)

Upvotes: 0

Views: 5906

Answers (1)

Kanish
Kanish

Reputation: 546

The seaborn documentation has the exact example you are looking for. Following the documentation, if you run the below lines, it should generate the bar plot shown.

bar plot generated from the code

import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

titanic = sns.load_dataset("titanic")
exercise = sns.load_dataset("exercise")
g = sns.catplot("alive", col="deck", 
                col_wrap=3, data=titanic[titanic.deck.notnull()], 
                kind="count", height=2.5, aspect=.8)

The important argument to note here is kind="count".

Upvotes: 2

Related Questions