Ravindra BagaleCourses & study guides Track your progress

Guides

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:

  1. matplotlib.pyplot आणि seaborn import.
  2. Aggregated table पासून सुरू (गरज असल्यास groupby).
  3. Bar — cities / clients compare.
  4. Line — dates असल्यास trend.
  5. Hist — likes किंवा watches ची distribution.
  6. 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 charts Sales table without a chart.

Before — shop sales as numbers only.

After first bar Bar chart story; Mumbai 120.

After — first bar chart; Mumbai bar taller at 120.

Before: फक्त numbers. After: bar story — Mumbai उंच 120.

matplotlib vs seaborn

  1. matplotlib — foundational Figure/Axes.
  2. seaborn — pandas वर जलद statistical charts.
  3. दोन्ही वापरा; 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

  1. एका chart ला एक मुख्य message.
  2. Axes label; units गरज असल्यास.
  3. Chart junk टाळा — neon grids मुद्दा लपवतात.
  4. प्रत्येक 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

  1. प्रश्न: कोणती city shop sales मध्ये पुढे?
  2. Table: Mumbai 120, Pune 70.
  3. Chart: bar.
  4. वाक्य: “या extract वर Mumbai 120 ने पुढे.”
  5. Optional: फक्त Online filter करून पुन्हा draw.

Ravindra Bagale's Tip

Takeaway एका बोललेल्या वाक्यात सांगता येत नसेल तर chart तयार नाही — आधी aggregation किंवा title ठीक करा. समजलं का?

Practice task

  1. Mumbai 120 / Pune 70 bar plot.
  2. Markdown takeaway वाक्य.
  3. सहा like counts चा hist.
  4. “कोण जिंकला?” vs “spread कसा?” — कोणता chart.

समजलं का? 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.