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
