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

**URL:** https://discourse.julialang.org/t/how-to-plot-a-unfilled-histogram-stairs-in-makie/135977
**Category:** Visualization
**Tags:** plotting, statistics, makie
**Created:** [March 3, 2026, 2:09am UTC](https://discourse.julialang.org/t/how-to-plot-a-unfilled-histogram-stairs-in-makie/135977 "2026-03-03T02:09:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Abhro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abhro/32/220753_2.png) [@Abhro](https://discourse.julialang.org/u/Abhro)
#### Post date: [March 3, 2026, 2:09am UTC](https://discourse.julialang.org/t/how-to-plot-a-unfilled-histogram-stairs-in-makie/135977/1 "2026-03-03T02:09:46Z")

</div>

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:

```julia
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`.

---

<div class="post-metadata">

### Author: ![technocrat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/technocrat/32/220947_2.png) [@technocrat](https://discourse.julialang.org/u/technocrat)
#### Post date: [March 3, 2026, 3:28am UTC](https://discourse.julialang.org/t/how-to-plot-a-unfilled-histogram-stairs-in-makie/135977/2 "2026-03-03T03:28:16Z")

</div>

> [@Abhro](#):
>
> `plot`

```julia-auto
using CairoMakie
import StatsBase

# Generate sample data
sample = randn(5000)

# Fit the histogram using StatsBase
hfit = StatsBase.fit(StatsBase.Histogram, sample)

# 1. Plot an unfilled step histogram from raw data
# Use 'hist' with a transparent fill and a visible stroke
hist(sample, color = :transparent, strokewidth = 1, strokecolor = :black)

# 2. Plot a filled histogram from a fitted Histogram object
# 'barplot' requires the bin edges (x) and the weights (y)
barplot(hfit.edges[1][1:end-1], hfit.weights)

# 3. Plot a step histogram from a fitted Histogram object
# 'stairs' requires the edges and weights; we append a zero to the weights 
# to ensure the array lengths are compatible for the step plot.
stairs(hfit.edges[1], vcat(hfit.weights, 0), step = :post)

```
