Data Science · मराठी आवृत्ती
14.3 hue आणि boxplot
hue="status" मुळे प्रत्येक city मधल्या statuses वेगळ्या colors मध्ये दिसतात:
fig, ax = plt.subplots(figsize=(8, 4))
sns.countplot(data=df, x="city", hue="status", ax=ax)
ax.set_title("City × status counts (fictional)")
plt.xticks(rotation=30, ha="right")
fig.tight_layout()
plt.show()
Amount चा spread पाहण्यासाठी boxplot वापरू:
fig, ax = plt.subplots()
sns.boxplot(data=df, x="festival", y="amount", ax=ax)
ax.set_title("Amount spread by festival (fictional)")
plt.show()
Jupyter मध्ये steps
sns.set_theme(style="whitegrid")run करा.- City चा countplot करा.
- Festival नुसार mean amount चा barplot करा.
- hue="status" असलेला countplot करा.
- तो chart
figures/seaborn_city_status.pngमध्ये save करा.
या छोट्या sample मध्ये Diwali mean amount जास्त दिसेल. Hue chart मध्ये Cancelled फक्त Kolhapur खाली दिसतो.