Chapter 60: Plotting
1. What is Plotting actually? (Very clear definition first)
Plotting means drawing graphs, charts, curves, points, lines or any visual representation of data or mathematical functions on a 2D (sometimes 3D) surface so that we can see patterns, relationships, trends, or behavior at a glance.
In simple words:
- You have some numbers, data, equations, or measurements
- Instead of staring at long lists of numbers, you plot them → draw dots, connect them with lines, make bars, curves, areas, etc.
- After plotting, your brain can instantly understand things that would take minutes or hours to calculate by looking at numbers alone.
Examples everyone has seen in real life:
- Temperature vs Time graph (line goes up in summer, down in winter)
- Sales report bar chart (tall bars = good month, short bars = bad month)
- Speed vs Time curve in physics (shows acceleration)
- Stock price chart on phone app (zigzag line going up/down)
- Heartbeat ECG line in hospital monitor
So plotting = turning numbers into pictures that tell a story quickly.
2. Why do we plot? (Real reasons students should know)
- See patterns you can’t see in raw data Example: 100 temperature readings — hard to understand. Plot them → you instantly see “temperature rises every afternoon”.
- Compare things easily Example: Plot sales of Phone A vs Phone B → you see which one is winning without reading 200 numbers.
- Prove or understand math/physics Example: Plot y = x² → you see perfect parabola shape.
- Find mistakes / outliers Example: Most points follow a line, but one point is far away → probably measurement error.
- Predict future Example: Plot past sales → extend the line → guess next month.
- Make reports & presentations look professional Teachers, bosses, clients love graphs — not long tables.
3. Basic Types of Plots (Most Common Ones You Will Use)
| Plot Type | What it looks like | Best used for | Example in real life |
|---|---|---|---|
| Line Plot | Points connected by straight lines | Change over time (continuous data) | Temperature over 24 hours |
| Scatter Plot | Just individual dots (no connecting lines) | Relationship between two variables | Height vs Weight of students |
| Bar Chart | Vertical or horizontal bars | Compare categories / discrete values | Sales of different products |
| Histogram | Bars showing frequency distribution | How data is spread / distribution | Marks distribution in class |
| Pie Chart | Circle divided into slices | Show percentage / proportion | Budget: food 40%, rent 30%, etc. |
| Area Chart | Line plot with area filled below | Cumulative totals over time | Total users growth over months |
4. Your First Plotting Example – Very Simple Line Plot (Copy-Paste & Run)
We will use Python + Matplotlib (the most common tool students learn first in India for plotting).
Install once (if you haven’t): Open terminal/command prompt → type pip install matplotlib
Then create first-plot.py:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import matplotlib.pyplot as plt # Our data: hours of the day and temperature hours = [0, 3, 6, 9, 12, 15, 18, 21, 24] temperature = [22, 20, 19, 24, 30, 32, 29, 26, 23] # Create the plot plt.plot(hours, temperature, color='red', # line color marker='o', # circle at each point linestyle='-', # solid line linewidth=2, # thickness markersize=8) # size of dots # Add titles and labels plt.title("Temperature Over 24 Hours", fontsize=16) plt.xlabel("Time (hours)", fontsize=12) plt.ylabel("Temperature (°C)", fontsize=12) # Add grid for easy reading plt.grid(True, linestyle='--', alpha=0.7) # Show the plot plt.show() |
What you see when you run it:
- Red line with dots
- Starts low at night → rises in day → falls again
- Clear title, x-axis (hours), y-axis (temperature)
- Grid lines to read values easily
This is your first real plot — congratulations! 🎉
5. Step-by-Step: How We Made This Plot (Teacher Blackboard Style)
- Import libraryimport matplotlib.pyplot as plt → Matplotlib is the most popular plotting tool in Python
- Prepare two lists
- hours = x-axis values (independent variable)
- temperature = y-axis values (dependent variable)
- Plot commandplt.plot(x, y, options…) → Connects points with line, adds markers
- Add meaning
- Title: what the graph shows
- xlabel, ylabel: what each axis means
- Make it readable
- Grid
- Colors, line style, marker style
- Show itplt.show() — opens window with graph
6. Teacher’s Quick Tips (Hyderabad Student Style 😄)
- Always label axes + title — otherwise teacher will deduct marks!
- Use plt.grid(True) — makes reading values very easy
- Common mistake #1: Lists of different lengths → error
- Common mistake #2: Forget plt.show() → nothing appears
- Common mistake #3: No import matplotlib.pyplot as plt → NameError
- Pro tip: Add plt.tight_layout() at end → prevents label cutting
- Pro tip 2: Save plot for report: plt.savefig(‘mygraph.png’, dpi=300)
Understood what Plotting is now? Plotting is one of the most powerful skills in data science, engineering, physics, maths, economics — it turns boring numbers into clear stories.
Tell me honestly — do you want to go deeper right now?
- Bar chart example (compare 5 products sales)?
- Scatter plot (height vs weight)?
- Multiple lines on same graph (temperature vs humidity)?
- Plot y = x², y = sin(x), etc. (math functions)?
- Full 20-question plotting quiz?
Just say — we can build any plot together step by step! 🚀
