Chapter 60: Plotting
Plotting in the clearest, most patient, and detailed way possible.
Imagine I’m your favorite math/computer-science teacher who really wants you to understand deeply, not just memorize formulas or copy code. We are going to build the concept from zero — step by step, with simple language, visual thinking, real-life analogies, common mistakes, and many small, complete, runnable examples.
No rushing. No assuming you already know something. We will go slowly until plotting feels like second nature.
Plotting – Complete Introduction for Beginners
1. What is Plotting? (The honest, everyday explanation)
Plotting means drawing a visual picture (graph/chart/diagram) that shows how one thing changes when another thing changes.
In simple words:
- You have two groups of numbers (or more)
- You want to see the relationship between them
- So you draw dots, lines, bars, areas, curves on paper (or screen) to show the pattern
Real-life examples everyone understands:
| Real-life situation | What you plot (x-axis) | What you plot (y-axis) | What the picture shows |
|---|---|---|---|
| Temperature every hour during the day | Time (hours) | Temperature (°C) | How hot/cold it gets during the day |
| Your height every year from age 5 to 18 | Your age (years) | Height (cm) | How much you grew each year |
| Sales of ice cream every month | Month | Number of ice creams sold | Which months sell more ice cream |
| Speed of a car during a trip | Time | Speed (km/h) | When the car sped up or slowed down |
| Number of likes on your posts vs time posted | Time of posting | Number of likes | Best time to post for more likes |
Plotting = turning boring lists of numbers into a picture that tells a story at a glance.
2. The two most important axes (X and Y)
Every basic plot has two lines (axes):
- X-axis (horizontal) → usually the cause, input, or independent variable (time, age, price, month, distance…)
- Y-axis (vertical) → usually the effect, output, or dependent variable (temperature, height, sales, speed, likes…)
Rule of thumb (memorize this):
X-axis = “What I control / what changes first” Y-axis = “What happens because of it”
Examples:
- X = time → Y = temperature (temperature changes because time passes)
- X = study hours → Y = exam score (score depends on study hours)
3. Most common types of plots (with simple real-life names)
| Plot name (English name) | Technical name | What it looks like | Best used when… | Example in real life |
|---|---|---|---|---|
| Line plot / Line graph | Line chart | Connected dots with lines | Showing change over time / continuous data | Temperature over 24 hours |
| Scatter plot / Dot plot | Scatter chart | Just individual dots (no lines) | Showing relationship between two things | Height vs weight of students |
| Bar chart / Column chart | Bar chart | Tall rectangles (bars) | Comparing categories / discrete values | Sales by month (Jan, Feb, Mar…) |
| Pie chart | Pie chart | Circle cut into slices | Showing parts of a whole (percentages) | How your day is spent (sleep, study, play…) |
| Area chart | Area chart | Line + filled area below | Showing total amount + change over time | Total money saved every month |
| Histogram | Histogram | Bars showing frequency | Showing distribution / how often values occur | Test scores of class (how many got 60–70, etc.) |
4. Minimal complete plotting example in Python (Matplotlib)
Let’s start with the simplest possible plot — temperature over 8 hours.
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# Step 1: Import the plotting library import matplotlib.pyplot as plt # Step 2: Prepare two lists of numbers hours = [0, 1, 2, 3, 4, 5, 6, 7, 8] # X-axis: time in hours temperatures = [22, 21, 20, 21, 23, 26, 28, 27, 25] # Y-axis: °C # Step 3: Tell Python to plot them plt.plot(hours, temperatures, marker='o') # 'o' = show dots at each point # Step 4: Add titles & labels (very important!) plt.title("Temperature During Morning Hours") plt.xlabel("Time (hours after midnight)") plt.ylabel("Temperature (°C)") # Step 5: Show the picture plt.grid(True) # optional: add grid lines plt.show() |
What this code actually does (in plain English):
- We have two lists: hours (X) and temperatures (Y)
- plt.plot() connects the points with lines and shows dots (marker=’o’)
- We give the graph a title and label the X and Y axes so anyone can understand it
- plt.show() opens a window with the graph
What you see: A blue line going down then up — showing temperature dropped at night and rose in the morning.
5. Your first 3 tiny practice tasks (do them tonight)
Task 1 – Your daily screen time Make two lists: hours = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] screen_time = [0.5, 0.8, 1.2, 1.5, 2.0, 2.3, 2.8, 3.1, 2.5, 2.0, 1.5, 1.0] # hours per hour of day
Plot it → title = “My Screen Time Today”
Task 2 – Bar chart of favorite fruits fruits = [‘Apple’, ‘Banana’, ‘Orange’, ‘Mango’, ‘Grapes’] votes = [12, 18, 9, 15, 7]
Use plt.bar(fruits, votes) instead of plt.plot
Task 3 – Add colors & markers Take Task 1 again Add: plt.plot(hours, screen_time, color=’purple’, marker=’o’, linestyle=’–‘, linewidth=2)
Paste your code or screenshot here if you want feedback — I’ll review it like we’re sitting together improving it.
Which part still feels a little fuzzy?
- What X-axis vs Y-axis really means?
- Why we need titles and labels?
- Difference between line plot vs bar chart?
- How to read a graph (what the shape tells us)?
- Something else?
Tell me honestly — we’ll slow down and fix exactly the piece that’s confusing.
Plotting is one of the most useful skills in the world — once you master it, you can understand data, science, business, sports, health… everything better!
You’re doing great — let’s keep going! 🚀
