Data Science · मराठी आवृत्ती
14.2 countplot आणि barplot
countplot प्रत्येक category मधल्या rows मोजतो. City च्या row count नुसार chart चा क्रम ठेवू:
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()
barplot मात्र numeric value चं aggregation करतो. पुढे festival tag नुसार amount ची mean घेतली आहे; total नाही.
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()