Ravindra BagaleCourses & study guides

14. Visualization with seaborn

14.2 countplot and barplot

fig, ax = plt.subplots(figsize=(8, 4))
sns.countplot(data=df, x="city", order=df["city"].value_counts().index, ax=ax)
ax.set_title("Order lines by city (fictional)")
plt.xticks(rotation=30, ha="right")
fig.tight_layout()
plt.show()
fig, ax = plt.subplots(figsize=(7, 4))
sns.barplot(data=df, x="festival", y="amount", estimator="mean", errorbar=None, ax=ax)
ax.set_title("Mean amount by festival tag (fictional)")
ax.set_ylabel("Mean amount (₹)")
plt.show()