🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Data Science & Analytics › Data Visualization: Principles, Tools, and Storytelling › Lesson 4
TEC-DATA85-06 · Lesson 4 · 11 clock hours · lab

Statistical Visualization in Python: Seaborn and Distribution Plots

Objective. Students will build and interpret distribution, categorical, and relational Seaborn plots—including KDE, violin, pair plot, and heatmap—and correctly describe the statistical story each chart reveals in written captions.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

What Seaborn Is and Why It Matters

Seaborn is a Python data-visualization library built on top of Matplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics with less code than raw Matplotlib requires. Seaborn is tightly integrated with pandas DataFrames, meaning you can pass a DataFrame and column names directly to most plotting functions. For the Google Data Analytics, IBM Data Science Professional, CompTIA Data+, and Microsoft PL-300 credential paths, the ability to produce and interpret statistical charts quickly is a core professional skill.

Figure-Level vs. Axes-Level API

Seaborn organizes its functions into two tiers.

Axes-level functions draw onto a single Matplotlib `Axes` object. Examples include `histplot()`, `kdeplot()`, `violinplot()`, `scatterplot()`, and `heatmap()`. You can embed these into any Matplotlib figure layout you build yourself.

Figure-level functions create their own `Figure` and can produce multi-panel grids automatically. Examples include `displot()`, `relplot()`, `catplot()`, `lmplot()`, and `pairplot()`. They return a Seaborn grid object, not a plain Axes, so the syntax for adding titles or saving differs slightly. Always check the Seaborn documentation at seaborn.pydata.org to confirm which tier a function belongs to before you combine it with Matplotlib calls—mixing them incorrectly is a common source of errors.

Distribution Plots: Histograms and KDE

A histogram divides a numeric variable into bins and counts observations per bin, revealing the overall shape of a distribution. A Kernel Density Estimate (KDE) plot smooths that histogram into a continuous curve, making it easier to see whether the distribution is unimodal, bimodal, skewed, or roughly normal. In Seaborn you can produce a KDE alone with `kdeplot()`, or combine a histogram and KDE in one call using `displot(kind='hist')` with `kde=True`.

When describing a KDE, state: (1) the approximate center, (2) the spread or width, and (3) the shape—symmetric, right-skewed (long tail to the right), or left-skewed (long tail to the left).

Categorical Plots: Violin and Box

A violin plot (`violinplot()`) is a hybrid: the outer shape is a mirrored KDE showing the distribution's density at each value, and an inner box plot shows the median and interquartile range. Violin plots are especially useful when you group a numeric variable by a categorical variable—for example, comparing life expectancy across world regions. A wider section of the violin means more data points cluster at that value.

When writing a caption, name the group with the highest or lowest median, note any visible difference in spread, and describe any notable skew visible in the violin shape.

Relational Plots: Scatter with Regression

`lmplot()` produces a scatter plot with an ordinary least-squares regression line and a shaded confidence interval overlaid. It is a figure-level function and supports a `hue` parameter to color points by a categorical variable and a `col` parameter to create small multiples. When describing this chart, state the direction of the relationship (positive or negative slope), an impression of its strength (points close to or far from the line), and whether any obvious outliers are visible.

Heatmaps and Correlation Matrices

A heatmap (`heatmap()`) encodes numeric values in a matrix as color. The most common use in data analytics is displaying a correlation matrix—a table where each cell holds the Pearson correlation coefficient between two numeric variables. Values range from −1 (perfect negative linear relationship) to +1 (perfect positive linear relationship); 0 means no linear relationship. Pass `annot=True` to print the numeric values inside each cell and `cmap='coolwarm'` for a diverging palette that visually distinguishes positive from negative correlations. Always set `vmin=-1` and `vmax=1` so the color scale is anchored consistently.

Pair Plots

`pairplot()` generates a grid of scatter plots for every numeric-variable pair in a DataFrame, with univariate distribution plots (histograms or KDE) along the diagonal. This is a quick exploratory tool—not a finished deliverable—for spotting which pairs of variables show linear trends or clusters. Pass `hue` to color by a categorical column and reveal group separation.

Writing Statistical Captions

Every chart you submit must include a two-sentence caption that (1) names the chart type and the variables displayed, and (2) states the key statistical finding in plain language. Example for a KDE: "This KDE plot shows the distribution of adult BMI in the health-indicator dataset. The distribution is unimodal and slightly right-skewed, with the bulk of values concentrated between 22 and 30." Vague captions such as "this chart shows BMI" do not earn full credit.

Workspace Safety and Data Responsibility

This is a software lab; traditional physical hazards such as electrical lockout/tagout are not present. However, professional data practice requires its own safety habits. Never commit real patient, financial, or personally identifiable data to a public repository. The provided health-indicator CSV contains de-identified public data—treat all health datasets as sensitive by default. Before publishing any analysis, verify that your charts do not inadvertently reveal small-group counts that could re-identify individuals. Save your work frequently and keep a backup copy of the original CSV—do not overwrite source data.

Key terms8

Kernel Density Estimate (KDE)A smoothed, continuous curve that estimates the probability density function of a numeric variable, showing distribution shape without discrete bins.
Violin plotA chart that combines a mirrored KDE (showing value density) with an inner box plot, used to compare distributions across categorical groups.
Figure-level functionA Seaborn function such as lmplot() or pairplot() that creates and manages its own Figure and can produce multi-panel grids automatically.
Axes-level functionA Seaborn function such as kdeplot() or violinplot() that draws onto a single Matplotlib Axes object and can be embedded in custom figure layouts.
Correlation matrixA square table of Pearson correlation coefficients between every pair of numeric variables in a dataset, ranging from -1 to +1.
lmplot()A Seaborn figure-level function that produces a scatter plot with an ordinary least-squares regression line and shaded confidence interval.
Pair plotA grid of scatter plots for every numeric-variable pair in a DataFrame, with univariate distribution plots on the diagonal, used for quick exploratory analysis.
Right-skewed distributionA distribution whose tail extends further to the right than the left, meaning most values are concentrated at lower values with a few high outliers pulling the mean upward.
In class: Instructor demonstration of Seaborn's figure-level vs. axes-level API distinction, with annotated live-coding of a pair plot and correlation heatmap on the Gapminder dataset. · Independent lab: students load a provided health-indicator dataset and complete a lab card requiring one KDE plot, one violin plot grouped by a categorical variable, one scatter plot with a regression line (lmplot), and one annotated heatmap—each with a two-sentence caption. · Class critique session: six student charts are projected anonymously; the group identifies one strength and one improvement for each, instructor records feedback on the board and connects comments to design principles from Lesson 2.
Materials: Jupyter Notebook, Python 3.x, Seaborn library, Gapminder dataset (gapminder.org/data/), provided health-indicator CSV, Seaborn official documentation (seaborn.pydata.org), lab card handout.
Check: Submitted notebook with four required charts and captions. Instructor scores captions for statistical accuracy (does the caption correctly name the distribution shape or correlation direction?). Pass = all four charts render, all four captions are statistically accurate.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Data visualization and Python tools
1. A student calls `violinplot()` directly on a Matplotlib Axes object. Which Seaborn API tier does this function belong to?
Statistical concepts and data interpretation
2. A KDE plot of household income shows a long tail extending to the right and the peak near a low value. Which term correctly describes this shape?
Statistical concepts and data interpretation
3. In a Seaborn heatmap of a correlation matrix, a cell displays a value of −0.85 colored in deep blue. What is the most accurate interpretation?
Data visualization and Python tools
4. Which Seaborn function should a student use to create a multi-panel scatter plot where each panel represents a different continent, with a regression line in each panel?
Data visualization and Python tools
5. A violin plot comparing blood pressure across three age groups shows that the violin for the oldest group is much wider at high values than the other two groups. What does this width indicate?
Data storytelling and communication
6. A student writes the caption: 'This chart shows cholesterol levels.' According to lesson standards, why is this caption insufficient?
Data visualization and Python tools
7. When generating a correlation heatmap with `sns.heatmap()`, which two arguments together ensure the color scale correctly represents the full range of possible Pearson correlation values?
Data ethics, governance, and security
8. A data analyst is preparing a health-indicator notebook for public upload to a code-sharing platform. Which practice best protects data privacy?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.