Skip to content

ridgeline

A ridgeline plot shows the densities of the samples for each parameter in a single axis by stacking them vertically.

Similar to the forestplot, this visualization does not contain information about each individual chain. Instead, it can provide a more concise overview of parameter distributions after the computational faithfulness of MCMC sampling has been validated.

julia
using ChainsMakie, CairoMakie
import MCMCChains: Chains
chains = Chains(randn(300, 2, 4), [:A, :B])
ridgeline(chains)

It is possible to plot a subset of the parameters by passing their names as the second argument:

julia
using ChainsMakie, CairoMakie
import MCMCChains: Chains
chains = Chains(randn(300, 3, 4), [:A, :B, :C])
ridgeline(chains, [:A, :B])

Attributes

color

Controls the color of each density plot.

Defaults to the first color in Makie's wong_colors palette.

julia
using ChainsMakie, CairoMakie
import MCMCChains: Chains
chains = Chains(randn(300, 2, 4), [:A, :B])
ridgeline(chains; color = :orange)

strokewidth

Controls the strokewidth of the density plot's contour.

Defaults to 1.0.

julia
using ChainsMakie, CairoMakie
import MCMCChains: Chains
chains = Chains(randn(300, 2, 4), [:A, :B])
ridgeline(chains; strokewidth = 2.0)

strokecolor

Controls the strokecolor of the contour around each density plot.

Defaults to the first color in Makie's wong_colors palette.

julia
using ChainsMakie, CairoMakie
import MCMCChains: Chains
chains = Chains(randn(300, 2, 4), [:A, :B])
ridgeline(chains; strokecolor = :black)

alpha

Controls the opacity of each density plot.

Defaults to 0.4.

julia
using ChainsMakie, CairoMakie
import MCMCChains: Chains
chains = Chains(randn(300, 2, 4), [:A, :B])
ridgeline(chains; alpha = 0.6)