matplotlib आणि seaborn ने पहिले charts (line, bar, hist)
Read this guide in: English · मराठी · हिंदी
तुमचे पहिले bar, line आणि histogram charts tables ला stories बनवतात. matplotlib आणि seaborn वापरा. Shop: Mumbai bar 120, Pune 70. Machine learning नाही.
चला मित्रांनो! Managers pictures आठवतात. आज प्रामाणिक पहिले charts — rank साठी bar, trend साठी line, distribution साठी hist. Labels स्पष्ट. समजलं का?
थोडक्यात उत्तर
उभा first-chart path:
matplotlib.pyplotआणिseabornimport.- Aggregated table पासून सुरू (गरज असल्यास groupby).
- Bar — cities / clients compare.
- Line — dates असल्यास trend.
- Hist — likes किंवा watches ची distribution.
- Title + axis labels + एक वाक्य takeaway.
question → aggregate → bar/line/hist → label → one message
Language: English · मराठी · हिंदी
या guide आधी काय हवं?
- Clean-enough DataFrame आणि स्पष्ट प्रश्न.
- Packages: matplotlib, seaborn (install guide).
- Course: Line and hist.
Before आणि after
Before — shop sales as numbers only.
After — first bar chart; Mumbai bar taller at 120.
Before: फक्त numbers. After: bar story — Mumbai उंच 120.
matplotlib vs seaborn
- matplotlib — foundational Figure/Axes.
- seaborn — pandas वर जलद statistical charts.
- दोन्ही वापरा; week one धर्मयुद्ध नको.
Bar chart — shop sales
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame({"city": ["Mumbai", "Pune"], "sales": [120, 70]})
sns.barplot(data=df, x="city", y="sales")
plt.title("Shop sales by city")
plt.ylabel("Sales")
plt.show()
काय दिसेल: Mumbai bar उंच. काय बोला: “Mumbai 120 vs Pune 70 ने पुढे.”
Line chart — daily trend (suppose)
Day1 40, day2 50, day3 100:
daily = pd.DataFrame({"day": [1, 2, 3], "sales": [40, 50, 100]})
plt.plot(daily["day"], daily["sales"], marker="o")
plt.title("Online sales trend")
plt.xlabel("Day")
plt.ylabel("Sales")
plt.show()
Line = वेळेतील हालचाल. Bar = categories compare.
Histogram — Instagram-like likes
likes = pd.Series([80, 40, 70, 30, 90, 20])
plt.hist(likes, bins=5)
plt.title("Distribution of post likes")
plt.xlabel("Likes")
plt.ylabel("Count of posts")
plt.show()
Spread दाखवतो — कोण जिंकला नाही. वेगळा प्रश्न → वेगळा chart.
Chart ↔ प्रश्न
| Question | Chart |
|---|---|
| कोणी जास्त विकलं? | Bar |
| दिवसानुसार sales कशी हलली? | Line |
| likes कसे पसरले? | Hist |
| दुसऱ्या split सह categories | Bar + hue (seaborn) |
Storytelling rules
- एका chart ला एक मुख्य message.
- Axes label; units गरज असल्यास.
- Chart junk टाळा — neon grids मुद्दा लपवतात.
- प्रत्येक row line-item असेल तर plot आधी aggregate.
Axis formatting (simple)
Readable ticks; city names rotate; sales counts साठी bar baseline zero पासून (दुर्मिळ documented कारण नसेल तर).
seaborn extras
sns.countplot, hue ने channel split, नंतर boxplot.
End-to-end mini story
- प्रश्न: कोणती city shop sales मध्ये पुढे?
- Table: Mumbai 120, Pune 70.
- Chart: bar.
- वाक्य: “या extract वर Mumbai 120 ने पुढे.”
- Optional: फक्त Online filter करून पुन्हा draw.
Ravindra Bagale's Tip
Takeaway एका बोललेल्या वाक्यात सांगता येत नसेल तर chart तयार नाही — आधी aggregation किंवा title ठीक करा. समजलं का?
Practice task
- Mumbai 120 / Pune 70 bar plot.
- Markdown takeaway वाक्य.
- सहा like counts चा hist.
- “कोण जिंकला?” vs “spread कसा?” — कोणता chart.
Learn it properly
Related: EDA checklist · groupby aggregation
समजलं का? Rank साठी bar, trend साठी line, spread साठी hist. Label. Message बोला. Mumbai 120 स्पष्ट दिसायला हवं. आता पुढे जाऊया.
Frequently asked questions
matplotlib vs seaborn?
matplotlib is the base. seaborn gives faster statistical charts. Use both; the course compares them.
Which chart first?
Bar for category comparison. Line for time. Hist for distribution of one numeric column.
My bars look wrong
Check aggregation — plot groupby totals, not duplicated raw rows by mistake.
Do I need colour fireworks?
No. Clear labels beat neon themes in interviews and client work.
Where does storytelling fit?
Match chart to question — course chapter 15. One page, one manager message.
Course links?
matplotlib line/hist, seaborn bar/count, chart choice chapters.