Skip to content
Tutorials Center
My learning

Topics

Lesson 11 of 57 ยท Describing Data

Visualizing Distributions

Pick the right chart for your data: histograms, bar charts, box plots, density curves and scatter plots, with Matplotlib examples and tips for honest, readable graphs.

Numbers summarize, pictures reveal. A histogram can show two peaks that no mean would ever hint at, and a scatter plot can expose a curve where a correlation coefficient sees nothing. Always plot your data before computing statistics. This lesson covers the core charts and when to use each.

Choosing a chart

Data Question Chart
One categorical variable How common is each category? Bar chart
One numeric variable What is its shape? Histogram, density plot
Numeric across groups How do groups compare? Box plot, side-by-side histograms
Two numeric variables Are they related? Scatter plot
Numeric over time What is the trend? Line chart
Parts of a whole (few parts) What are the shares? Bar chart (pie only for 2 to 4 parts)

Bar charts for categories

A bar chart gives each category a bar whose height is its count or percentage. Bars have gaps between them because the categories are separate, and they must start at zero: a truncated axis exaggerates differences.

Python A bar chart of categories

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Histograms for numeric data

A histogram groups numeric values into bins (the same idea as the frequency table) and draws bars with no gaps, because the values form a continuous scale. The bar height shows the count in that bin. The shape of the histogram tells you about symmetry, spread, peaks and outliers.

The number of bins matters. Too few hides detail, too many looks noisy. A good starting point is the square root of n, or let software choose (bins="auto").

Python Histogram of a bimodal sample

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The mean falls near 8, in the valley between two peaks where almost no one actually waits. The histogram shows what the mean hides.

Density curves

A density curve is a smoothed histogram, scaled so the total area is 1. The area under the curve between two values is the proportion of data in that range. It reappears in the lessons on continuous random variables.

Box plots to compare groups

Box plots (see quartiles and outliers) are compact enough to place many groups next to each other. Use them when you care about medians, spread and outliers across groups rather than the detailed shape.

Python Compare three groups with box plots

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Scatter plots for relationships

A scatter plot places each observation as a point using two numeric variables. It reveals direction (positive or negative), form (straight, curved), strength (tight or loose cloud) and outliers. It is the starting point for correlation and regression.

Python A scatter plot with a trend

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Line charts for time

Connect points in time order. Use them for series where the order matters (monthly sales, daily temperature). Do not use lines to connect unrelated categories.

Honest charts: a checklist

  1. Start bars at zero. Lines and scatter plots may start elsewhere, but say so.
  2. Label both axes with units, and add a descriptive title.
  3. Avoid 3D effects and decorations that distort areas.
  4. Limit colors and use them to carry meaning, not decoration.
  5. Choose bins deliberately and try more than one.
  6. Prefer simple charts. If you need a paragraph to explain the chart, simplify it.
flowchart TD
    A["How many variables?"] --> B["One"]
    A --> C["Two"]
    B --> B1["Categorical: bar chart"]
    B --> B2["Numeric: histogram or box plot"]
    C --> C1["Both numeric: scatter plot"]
    C --> C2["Numeric by group: box plots"]
    C --> C3["Over time: line chart"]

Start with the data type and the question, then choose the chart.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which chart is best for the shape of one numeric variable?

    A histogram shows how values are distributed across bins.
  2. 2. Why should bar charts start at zero?

    Readers compare bar lengths as proportions, so a truncated axis misleads.
  3. 3. A histogram has two clear peaks. What does this suggest?

    Bimodal data often come from two subpopulations that should be examined separately.
  4. 4. To explore the relation between two numeric variables, use a...

    Scatter plots show direction, form and strength of the relationship.

Summary

  • Pick the chart from the data type and the question you are asking.
  • Bar charts show categories (start at zero); histograms show numeric shape; box plots compare groups; scatter plots show relationships.
  • Bin choice can change a histogram's story, so try several.
  • A plot can reveal structure (like two peaks) that summary numbers hide.
  • Label axes, avoid distortion and keep charts simple.

Next: Sample Spaces and Events