DEV Community

TianYi Zhang
TianYi Zhang

Posted on

What is a Stem-and-Leaf Plot? A Complete Guide

A stem-and-leaf plot is a semi-tabular format for displaying the distribution of quantitative data. Each value is split into a stem (the leading digits) and a leaf (the final digit), preserving every original data point while revealing the shape of the distribution at a glance. Invented by statistician John Tukey in the 1970s, it remains a staple of introductory statistics courses worldwide.


Key Terms

Term Definition
Stem The leading digit(s) of a number. For 73, the stem is 7. For 125, the stem is 12
Leaf The final digit of a number. For 73, the leaf is 3. For 125, the leaf is 5. Leaves are always single digits from 0 to 9
Key Explains how to reconstruct values from stems and leaves. For example, "2 | 3 = 23" means stem=2, leaf=3 → value 23
Distribution The overall pattern of data revealed by the arrangement of leaves across stems — symmetry, skewness, gaps, and clusters

Why Use Stem-and-Leaf Plots?

  • Preserve every data point. Unlike histograms that group values into bins, a stem-and-leaf plot keeps each individual number, so no information is lost.
  • See distribution shape instantly. The arrangement of leaves naturally reveals the shape of the data — symmetry, skewness, gaps, and clusters are visible at a glance.
  • Perfect for small datasets. When you have 10 to 50 values, a stem-and-leaf plot provides a clear, compact view without the bin-width decisions required by histograms.
  • Easy to create by hand or online. The format is simple: split each number into stem and leaf, then sort. This free online tool does the computation automatically.
  • Ideal for education. Stem-and-leaf plots are widely used in middle school, high school, and college statistics courses to teach data organization, median finding, and distribution analysis.
  • Recover original data. Unlike histograms and box plots, you can reconstruct every exact original value from the display.

Stem-and-Leaf vs Box Plot vs Histogram

All three belong to John Tukey's exploratory data analysis (EDA) toolkit, each with distinct strengths:

Chart Preserves raw values Shows distribution Best data size
Stem-and-Leaf ✓ Every value visible ✓ Leaf arrangement shows shape 10–50, optimal
Box Plot ✗ Only five-number summary ✓ But hides multi-modal patterns Any size
Histogram ✗ Grouped into bins ✓ But sensitive to bin width 20+

Worked Example

We'll use the Test Scores sample from the tool — 20 students' exam scores:

52, 58, 63, 67, 71, 74, 78, 82, 85, 88, 91, 94, 97, 99, 72, 64, 81, 76, 93, 55
Enter fullscreen mode Exit fullscreen mode

Step 1: Split Each Value into Stem and Leaf

Split each number into stem (tens digit) and leaf (ones digit). For example, 52 → stem=5, leaf=2; 71 → stem=7, leaf=1:

52 → stem5 leaf2    58 → stem5 leaf8    63 → stem6 leaf3
67 → stem6 leaf7    71 → stem7 leaf1    74 → stem7 leaf4
78 → stem7 leaf8    82 → stem8 leaf2    85 → stem8 leaf5
88 → stem8 leaf8    91 → stem9 leaf1    94 → stem9 leaf4
97 → stem9 leaf7    99 → stem9 leaf9    72 → stem7 leaf2
64 → stem6 leaf4    81 → stem8 leaf1    76 → stem7 leaf6
93 → stem9 leaf3    55 → stem5 leaf5
Enter fullscreen mode Exit fullscreen mode

Step 2: Group by Stem, Sort Leaves

Stem | Leaf
5    | 2 5 8
6    | 3 4 7
7    | 1 2 4 6 8
8    | 1 2 5 8
9    | 1 3 4 7 9

Key: 5 | 2 = 52
Enter fullscreen mode Exit fullscreen mode

Step 3: Interpret

  • Stem 5 (50–59 pts): 3 students, lower scores
  • Stem 6 (60–69 pts): 3 students
  • Stem 7 (70–79 pts): 5 students, the largest group
  • Stem 8 (80–89 pts): 4 students
  • Stem 9 (90–99 pts): 5 students, strong high-end presence

The leaf arrangement reveals a mild bimodal pattern — two peaks at the 70–79 and 90–99 ranges, with slightly fewer students in the 80–89 range. Overall scores are high with no extreme low outliers.


Back-to-Back Stem-and-Leaf Plot

When comparing two datasets, you can share a central "Stem" column with leaves from the first group on the left and leaves from the second group on the right — a back-to-back display.

We'll use the Back-to-Back: Math vs Physics sample from the tool:

Math scores:

72, 85, 78, 90, 65, 88, 76, 92, 70, 84, 79, 86, 74, 91, 68
Enter fullscreen mode Exit fullscreen mode

Physics scores:

68, 75, 82, 70, 88, 74, 80, 66, 85, 73, 90, 72, 69, 77, 81
Enter fullscreen mode Exit fullscreen mode

The back-to-back stem-and-leaf plot:

       Math           Stem       Physics
       5 8             6         6 8 9
     0 2 4 6 8 9       7         0 2 3 4 5 7
     4 5 6 8           8         0 1 2 5 8
     0 1 2             9         0

Key: 6 | 5 = 65
Enter fullscreen mode Exit fullscreen mode

From this display we can see immediately: Math scores are generally higher and more spread out (65–92, with leaves across four stems 6–9), while Physics scores are more concentrated (66–90, with most leaves in stems 7 and 8). Physics also has more low-scoring students (3 at stem 6 vs. Math's 2).


Stem-and-Leaf Plot Result

The chart was generated by https://aiboxplot.com


Extended Forms

Split Stems

When data is concentrated in a narrow range, each stem can be split into two (e.g., 5 for leaves 0–4, 5* for leaves 5–9) to reveal finer detail:

Stem | Leaf
5    | 2 3 4
5*   | 5 6 7 8 8 9
6    | 0 1 2 2 3
6*   | 5 6 7 8 9 9
Enter fullscreen mode Exit fullscreen mode

Computation Logic

function computeStemLeaf(data) {
  // 1. Sort
  const sorted = [...data].sort((a, b) => a - b);

  // 2. Split into stem and leaf, group by stem
  const groups = new Map();
  for (const value of sorted) {
    const stem = Math.floor(value / 10);
    const leaf = value % 10;
    if (!groups.has(stem)) groups.set(stem, []);
    groups.get(stem).push(leaf);
  }

  // 3. Convert to ordered rows
  const stems = Array.from(groups.keys()).sort((a, b) => a - b);
  const rows = stems.map(stem => ({
    stem,
    leaves: groups.get(stem),  // already sorted because input was sorted
  }));

  return {
    rows,
    minStem: stems[0],
    maxStem: stems[stems.length - 1],
    // Dynamic key: use first stem's first leaf as example
    key: `${rows[0].stem} | ${rows[0].leaves[0]} = ${rows[0].stem}${rows[0].leaves[0]}`,
  };
}

// Using the Test Scores sample data
const scores = [52, 58, 63, 67, 71, 74, 78, 82, 85, 88, 91, 94, 97, 99, 72, 64, 81, 76, 93, 55];
const { rows, key } = computeStemLeaf(scores);

// Output:
// rows = [
//   { stem: 5, leaves: [2, 5, 8] },
//   { stem: 6, leaves: [3, 4, 7] },
//   { stem: 7, leaves: [1, 2, 4, 6, 8] },
//   { stem: 8, leaves: [1, 2, 5, 8] },
//   { stem: 9, leaves: [1, 3, 4, 7, 9] },
// ]
// key = "5 | 2 = 52"
Enter fullscreen mode Exit fullscreen mode

Frequently Asked Questions

What is the minimum number of data points needed?

You need at least 3 data points to create a stem-and-leaf plot, but 10 to 50 points produce the best results. Too few and no pattern is visible; too many and the leaf columns become unwieldy.

What is the difference between a stem-and-leaf plot and a histogram?

A histogram groups data into bins and shows only frequencies (bar heights), discarding individual values. A stem-and-leaf plot preserves every data point — you can recover the exact original numbers from the display.

Can stem-and-leaf plots handle decimals?

Yes. For decimals like 7.3, 8.1, 9.6, the stem can be the integer part (7, 8, 9) and the leaf the decimal part (3, 1, 6). The key must specify this, e.g., "7 | 3 = 7.3".

Can stem-and-leaf plots handle three-digit numbers?

Yes. For three-digit numbers like 125, 138, 142, the stem is the first two digits (12, 13, 14) and the leaf is the last digit (5, 8, 2). Key example: "12 | 5 = 125".

Is there an online stem and leaf plot maker?

Yes. This tool provides a free online stem and leaf plot maker with support for both single-dataset and back-to-back (dual-dataset) modes. Paste your data to generate instantly — no sign-up, no watermarks.

Why are stem-and-leaf plots widely used in education?

Because the operation is simple (just split digits), the original data is preserved, and the distribution shape is immediately visible. Students who create stem-and-leaf plots by hand gain a deep understanding of data organization and the intuitive meaning of distribution.

Top comments (0)