Line/Bar/Histogram बनाना
Line charts trends दिखाते हैं, bar charts categories compare करते हैं और histograms दिखाते हैं कि values कैसे distributed हैं।
In this page:
Syntax
df.plot(kind="line")
df.plot(kind="bar")
df["column"].plot(kind="hist", bins=n)
Line/bar/histogram
kind="line" time जैसे ordered data के लिए उपयुक्त है। kind="bar" (या .plot.bar()) categories compare करता है, और kind="hist" numeric values को bin करता है। bins histogram resolution control करता है। horizontal bars के लिए kind="barh" का उपयोग करें।
Note:
value_counts().plot.bar() category frequencies का एक तेज़ chart है।
उदाहरण: Line/bar/histogram
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import pandas as pd
s = pd.Series([3, 5, 5, 6, 8, 8, 8, 9])
kinds = []
for kind in ["line", "bar", "hist"]:
fig, ax = plt.subplots()
s.plot(kind=kind, ax=ax)
kinds.append((kind, len(ax.patches) or len(ax.lines)))
plt.close(fig)
print(kinds)
# Output:
# [('line', 1), ('bar', 8), ('hist', 10)]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- unordered categories के लिए line chart का उपयोग करना
- बहुत ज़्यादा histogram bins
- unsorted categories को plot करना
चैप्टर सारांश
- trends के लिए line
- categories के लिए bar
- distributions के लिए hist
- bins resolution सेट करता है
🔒
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: