Skip to content

Beginner: data foundations · Cleaning, exploring and visualising data · topic 21 of 62 · 30 min

Visualising data honestly

Explanation

A good chart answers one question at a glance. Choose the chart by the question: bars to compare groups, lines for change over time, histograms for spread, scatter plots for relationships. Label everything, start bar axes at zero and use colours everyone can read.

Why charts matter

Most people who use your analysis will never read your code or your tables. A clear chart is how your work reaches managers, clients and the public. A misleading chart, even an accidental one, can lead to bad decisions. So choosing and drawing charts well is part of being a data professional, not decoration.

Pick the chart by the question

QuestionChartExample
How do groups compare?Bar chartSales by city
How did it change over time?Line chartDaily UPI transactions over a year
How are values spread?Histogram or box plotDelivery times
Do two numbers move together?Scatter plotDistance vs delivery time
What share is each part of a whole?Stacked bar (or a pie with 2–4 slices)Payment methods used

Drawing a chart with matplotlib

python
import matplotlib.pyplot as plt

cities = ["Pune", "Delhi", "Mumbai"]
sales = [1230, 1350, 2100]

fig, ax = plt.subplots(figsize=(6, 4))
ax.bar(cities, sales, color="#2563eb")
ax.set_title("Sales by city, March 2025")
ax.set_ylabel("Sales (₹)")
ax.set_ylim(0, None)          # bars must start at zero
plt.tight_layout()
plt.show()
matplotlib is the base plotting library; seaborn and plotly build on similar ideas. Shown only.

Rules for honest charts

  • Start the value axis of a bar chart at zero. Bars show size by length; cutting the axis makes a 2% difference look like 200%.
  • Line charts may zoom in on a range, but say so clearly on the axis.
  • Label axes with units (₹, minutes, %), add a title that says what and when, and name the data source.
  • Do not use 3-D effects; they distort sizes.
  • Keep the same scale when you compare charts side by side.
  • Show the number of data points when it is small, so nobody over-reads 5 values.

Colour

About 1 in 12 men and 1 in 200 women have some colour vision deficiency, most often trouble telling red from green. Use colour-blind-friendly palettes (for example the "viridis" colour map or the Okabe-Ito colours), do not rely on red vs green alone, and use colour only when it carries meaning. One highlight colour against grey is often clearer than a rainbow.

Histograms and bins

A histogram splits a number range into equal bins (for example 0–10, 10–20 minutes) and draws how many values fall in each. The bin width changes the story: too wide hides detail, too narrow looks noisy. Try a few widths before choosing.

Think of it like this: A chart is like a road sign. A good sign is read in two seconds, has one message and never points the wrong way. Nobody wants a beautiful sign that sends drivers into a lake.

Common mistakes

  • Pie charts with many slices. Fix: use a sorted bar chart.
  • Two different y-axes on one chart that suggest a link that is not there. Fix: use two separate charts.
  • Default titles like "Figure 1". Fix: write the takeaway: "Mumbai sold the most in March".
  • Plotting averages without showing spread. Fix: add a box plot or error bars where it matters.

Need help?

Stuck on a word or an idea? Search this course, or every course, and jump straight to the explanation or a worked question.

Try:

Watch the lesson

Visualising data honestly · 1/7

Visualising data

A chart should answer one question at a glance. Let us learn to pick and draw honest charts.

Prefer a video by a teacher? Find free videos on “matplotlib tutorial data visualization best practices misleading charts” on YouTube ↗

In real life: A misleading election chart

A TV channel shows two party vote shares, 41% and 39%, as bars whose axis starts at 38%. The first bar looks three times taller than the second, though the gap is only 2 points. A careful analyst redraws it with the axis from 0 and adds the margin of error, which shows the race is close. Viewers are frequently misled by cut axes like this, which is why the zero rule exists for bars.

Practice (0/2 done)

Task 1 · Code · Python

Write histogram_counts(values, width) that puts numbers into bins of the given width starting at 0: bin 0 holds 0 ≤ v < width, bin 1 holds width ≤ v < 2·width, and so on. Return a dict mapping each bin's START value to its count, only for bins that have at least one value. Example: histogram_counts([3, 12, 15, 27], 10) returns {0: 1, 10: 2, 20: 1}. Values are never negative.

Task 2 · Practice

For each question, name the best chart and one rule you would follow when drawing it: (1) monthly revenue of a shop over two years, (2) number of students per course in a college, (3) spread of exam marks, (4) whether study hours relate to marks.

Quick quiz

Question 1

1.Which chart is best for daily UPI transaction counts over one year?

Question 2

2.Why must a bar chart's value axis start at zero?

Question 3

3.Which colour choice is the most accessible?

Question 4

4.You want to see how delivery times are spread. Which chart?

Question 5

5.What is the best chart title?

Read more (free)

Open a question to see the answer and why. The first ones are this topic's own quiz, so try the quiz above before you peek.

Which chart is best for daily UPI transaction counts over one year?

Answer: Line chart

Change over time is shown best with a line.

Why must a bar chart's value axis start at zero?

Answer: Bar length shows size, so a cut axis exaggerates differences

A bar twice as long should mean twice as much.

Which colour choice is the most accessible?

Answer: A colour-blind-friendly palette with one highlight colour

Red-green colour blindness is common, and fewer, purposeful colours are clearer.

You want to see how delivery times are spread. Which chart?

Answer: Histogram

A histogram shows the distribution of one numeric variable.

What is the best chart title?

Answer: Mumbai had the highest sales in March 2025

A title that states the takeaway and the period helps readers instantly.

Why look at distributions and not just averages?Related

Answer: Very different data can have the same average; the shape shows skew, gaps and outliers

Two datasets can share a mean while one is tight and the other is wild.

From Exploratory data analysis (EDA)

Walking DOWN an org chart, which join goes in the recursive member?Related

Answer: JOIN chain c ON e.manager_id = c.id

Find employees whose manager was found in the previous round. The other way walks up.

From Recursive CTEs

What is the job of an agenda at the start of a talk?Related

Answer: To tell people what you will cover

The agenda is the route map: "Today I'll talk about three things."

From Presentations that people remember

The chart default is replicaCount: 2, values-prod.yaml sets 6, and the command adds --set replicaCount=8. What is used?Related

Answer: 8

--set has the highest priority, above values files and chart defaults.

From Helm and Kustomize

Pass the quiz (60% or more) or mark this topic as done when you are ready.

Your progress is saved on this device only.

Next steps

  1. This is the last topic of “Cleaning, exploring and visualising data”. The module exam comes next.
  2. Module 4 exam: Cleaning, exploring and visualising data · 12 questions · 25 min, without help. 6 topics of this module still to finish first.
  3. Then the next module, The ML workflow, regression and classification. 62 topics left in the course before the final exam.

← Previous: Exploratory data analysis (EDA)