Skip to content

Misleading introductory sentence about sns.histplot behavior (Chapter 9) #214

@Andre-Leandro

Description

@Andre-Leandro

Description

On Chapter 9, the text says:

“seaborn makes histograms and density plots even easier through its histplot method, which can plot both a histogram and a continuous density estimate simultaneously.”

The problem is that this wording can mislead readers. It suggests that both the histogram and KDE will be shown together by default, but the example that follows only displays a histogram:

comp1 = np.random.standard_normal(200)
comp2 = 10 + 2 * np.random.standard_normal(200)

values = pd.Series(np.concatenate([comp1, comp2]))

sns.histplot(values, bins=100, color="black")

This creates a mismatch between the explanation and the actual output.
The KDE curve is not included unless kde=True is specified.


Suggested Fix

I suggest rephrasing the introductory sentence to avoid setting the wrong expectation.
For example:

“seaborn makes histograms and density plots even easier through its histplot method, which by default plots a histogram, and can optionally also show a continuous density estimate (by setting kde=True).”

This way, the sentence accurately reflects what the example demonstrates and prevents confusion for readers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions