← Back to Pandas Course | Chapter 12: Visualization Basics | Lesson 2 of 6

Line/Bar/Histogram बनाना

Line charts trends दिखाते हैं, bar charts categories compare करते हैं और histograms दिखाते हैं कि values कैसे distributed हैं।

In this page:

  1. Line/bar/histogram
Syntax
python
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

python
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. #}
आम गलतियां
  1. unordered categories के लिए line chart का उपयोग करना
  2. बहुत ज़्यादा histogram bins
  3. 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:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.