MatplotlibXBy @CodeWithMunnaX
Catalog
Track: Essential Charts
Multivariate Data12 mins

14. Scatter Plots, Sizing & Colormaps

Scatter plots reveal relationships, correlations, clusters, and anomalies between two or more continuous variables without connecting them with lines.

Mental Model Intuition

Constellations of stars in the night sky where brightness represents brightness, position represents sky coordinates, and star size represents mass.

Core Concepts & Mechanics

The 4 Dimensions of `scatter()`Multivariate

1. `x` (horizontal position), 2. `y` (vertical position), 3. `s` (marker area in points^2), 4. `c` (color array mapped via `cmap`).

A single scatter plot can display 4 distinct variables at once.
plt.scatter(x, y, s=size_arr, c=color_arr, cmap='plasma')

Common Beginner Mistakes & Pro Fixes

Avoid the top errors and bad plotting practices that trip up new Python developers

Troubleshooting

Quick Lesson Takeaways

  • `plt.scatter(x, y)` plots unlinked data points.
  • `s` controls individual point sizes.
  • `c` and `cmap` map numerical values to continuous color gradients.
  • `plt.colorbar()` renders the legend scale for colormaps.
Topic 14 • Python IDE
Python 3.12 • Matplotlib
Run Python code to inspect terminal output.

Real-World Datasets (1-Click Switcher)

Switch from abstract numbers to relatable Cricket, Cinema & Business charts

5 Curated Datasets

Hands-on Challenge: Draw a Scatter Plot

+50 XP

Write Matplotlib code to solve the objective and see your live plot render

Objective Instructions:

Plot `x=[1, 2, 3, 4, 5]` and `y=[2, 5, 8, 11, 14]` with `s=80` and `color='#00D9C0'`.

Required Keywords:✓ plt.scatter✓ s
Challenge Code Editor
Challenge Output GraphLive Vector Preview
Write code on the left to render live challenge plot
End of Lesson Knowledge Check

Quick Mini Quiz: 2 Concept Questions

Test your understanding to unlock the lesson completion badge

Q1

Which Matplotlib function is used to create a standard continuous 2D line plot?

Q2

What must you call after specifying label='...' so that the legend actually appears on the canvas?

0 of 2 answered