Reputation: 9
Here's an example:
titanic = sns.load_dataset("titanic")
g = titanic.groupby('embark_town').count()['survived']
g.plot(kind='bar')
I'm trying for a while to make it count x town, how can I do it?
Upvotes: 0
Views: 725
Reputation: 3594
You can supply kind='barh'
instead of kind='bar'
in the g.plot
:
import matplotlib.pyplot as plt
import seaborn as sns
titanic = sns.load_dataset("titanic")
g = titanic.groupby('embark_town').count()['survived']
g.plot(kind='barh')
plt.tight_layout()
plt.show()
Or you can use g.plot.barh()
import matplotlib.pyplot as plt
import seaborn as sns
titanic = sns.load_dataset("titanic")
g = titanic.groupby('embark_town').count()['survived']
g.plot.barh()
plt.tight_layout()
plt.show()
Upvotes: 1