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

Scatter Plot बनाना

Scatter plot हर row को एक dot के रूप में दिखाता है ताकि आप दो numeric columns के बीच संबंध देख सकें।

In this page:

  1. Scatter plot
Syntax
python
df.plot.scatter(x="column1", y="column2", c="color", s=size)

Scatter plot

df.plot.scatter(x, y) हर row के लिए एक point बनाता है। extra dimensions जोड़ने के लिए colour के लिए c और size के लिए s का उपयोग करें। Scatter plots correlation, clusters और outliers उजागर करते हैं।

Note: df.corr() numeric correlation देता है जो आप देखते हैं उससे मेल खाता है।

उदाहरण: Scatter plot

python
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
import pandas as pd

df = pd.DataFrame({"hours": [1, 2, 3, 4, 5], "score": [52, 58, 65, 70, 78]})
ax = df.plot.scatter(x="hours", y="score")
print("points:", len(ax.collections[0].get_offsets()))
print("correlation:", round(df["hours"].corr(df["score"]), 3))

# Output:
# points: 5
# correlation: 0.998
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. non-numeric columns को plot करना
  2. overplotting को नज़रअंदाज़ करना
  3. correlation को causation समझना
चैप्टर सारांश
  • scatter दो numeric columns दिखाता है
  • c और s colour और size जोड़ते हैं
  • correlation उजागर करता है
  • Points rows होते हैं
🔒

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.