liveBook · Manning

Ridgeline plot

As explained in The Well-Grounded Data Analyst

A ridgeline plot is a visualization that displays multiple distributions as overlapping, vertically offset density or frequency plots.

A ridgeline plot displays multiple distributions as overlapping, vertically offset density or frequency plots. It offers a compact alternative to separate histograms or box plots when comparing groups. section 10.4.3

Use a ridgeline plot when the analytical question concerns distribution rather than a single summary value:

  • Compare how property prices are distributed across years or geographic groups. section 10.4.3
  • Expose spread and changes in distribution that median-price heatmaps do not show. section 10.4.3
  • Conserve space by overlapping group plots, while accepting a more visually adventurous presentation. section 10.4.3

Welsh property prices

Build one price list per year, filter prices below £500,000, and pass the lists with year labels to ridgeplot. For a current geographic comparison, build one list per county using 2023 sales, then label the ridges by county. section 10.4.3

counties = sorted(wales["county"].unique())
sales_by_county = []

for county in counties:
    prices = (
        wales
        .loc[(wales["county"] == county)
             & (wales["sale_price"] < 500_000)
             & (wales["year"] == 2023),
        "sale_price"]
    )
    sales_by_county.append([prices])

fig = ridgeplot(sales_by_county,
                labels=counties,
                colorscale="gray",
                coloralpha=0.9,
                colormode="mean-minmax",
                spacing=0.7)

fig.update_layout(
    title="Sale prices in Wales in 2023, by county",
    height=650,
    width=950,
    font_size=12,
    plot_bgcolor="rgb(245, 245, 245)",
    xaxis_gridcolor="white",
    yaxis_gridcolor="white",
    xaxis_gridwidth=2,
    yaxis_title="County",
    xaxis_title="Sale price (£)",
    showlegend=False
)

fig.show()

Browse the county-level implementation, including filtering, list construction, labels, styling, and layout settings. section 10.4.3

How The Well-Grounded Data Analyst covers it

How deep it goes
Explains the visual rationale and demonstrates list preparation and styling, but stops short of density-estimation internals.
Examples
Uses Welsh property sale prices grouped by year and by county for 2023.
What it assumes
Assumes grouped sale-price data and basic exploratory visualization, while demonstrating the required list-based input structure.
What you can do after
Build it from scratch with grouped price lists, labels, filters, and ridgeplot layout settings.
How it connects
Connects distributions with histograms, box plots, heatmaps, medians, outliers, and exploratory data analysis.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Well-Grounded Data Analyst. The section links point to the parts of the book it draws on.