*61*

A stem-and-leaf plot is a chart that displays data by splitting up each value in a dataset into a *stemÂ *and aÂ *leaf*. Itâ€™s a unique plot because it helps us visualize the shape of a distribution while still displaying the raw individual data values.

This tutorial explains how to create a stem-and-leaf plot in Python.

**Example: Stem-and-Leaf Plot in Python**

Suppose we have the following dataset in Python:

x = [32, 34, 35, 41, 44, 46, 47, 52, 52, 53, 56, 61, 62]

To create a stem-and-leaf plot for this dataset, we can use theÂ **stemgraphic **library:

pip install stemgraphic

Once this is installed, we can use the following code to create a stem-and-leaf plot for our dataset:

import stemgraphic #create stem-and-leaf plot fig, ax = stemgraphic.stem_graphic(x)

The way to interpret this plot is as follows:

- The number in the red box at the bottom of the plot displays the minimum number in the dataset (
**32**). - The number in the red box at the top of the plot displays the maximum number in the dataset (
**62**). - The numbers in the far left display the aggregated count of values in the plot. For example, the first row contains
**2**aggregated values, the second row contains**3**aggregated values, the third row containsÂ**5**aggregated values, and so on. - The numbers in the middle column display theÂ
*stems*, which are**3**,Â**4**,Â**5**, andÂ**6**. - The numbers in the far right column display theÂ
*leaves*.

This single plot provides us with a ton of information about the distribution of values in this dataset.

**Additional Resources**

An Introduction to Stem-and-Leaf Plots

Stem-and-Leaf Plot Generator