How to plot a unfilled histogram (stairs) in Makie?

Abhro
Tue, 03 Mar 2026 02:09:46 +0000
Visualization

If I have a pre-fiitted histogram, how would I plot an unfilled histogram with Makie.jl? I can use hist and stephist for the raw data, but I’m not sure what to do about a Histogram object from StatsBase.jl

Example:

using CairoMakie
import StatsBase

sample = randn(5000)
hfit = StatsBase.fit(StatsBase.Histogram, sample)

hist(sample)      # plot a filled histogram
stephist(sample)  # plot an unfilled histogram

plot(hfit)        # plot a filled histogram
barplot(hfit)     # plot a filled histogram
hist(hfit)        # errors out
stephist(hfit)    # errors out
stairs(hfit)      # errors out

I’m looking for something in the last section that creates a plot using only hfit.

2 posts - 2 participants