# Makie Bar Plots

**URL:** <https://discourse.julialang.org/t/makie-bar-plots/137098>\
**Category:** Visualization\
**Tags:** makie, cairomakie\
**Created:** [May 13, 2026, 6:30am UTC](https://discourse.julialang.org/t/makie-bar-plots/137098 "2026-05-13T06:30:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mervyn\_Larrier](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mervyn_larrier/32/37709_2.png) [@Mervyn\_Larrier](https://discourse.julialang.org/u/Mervyn_Larrier)\
**Post date:** [May 13, 2026, 6:30am UTC](https://discourse.julialang.org/t/makie-bar-plots/137098/1 "2026-05-13T06:30:46Z")

</div>

I feel as though I’m probably missing something obvious, but there don’t seem to be a lot of examples for bar plots in Makie that don’t point you back towards AoG. How can I get these bars to be properly dodged? Here is the code I wrote, and included is an example result. I just want one data set on the left and the other on the right. Nothing fancy. Any help is greatyly appreciated.

```julia-auto
grades = df[:,1]
fig = CairoMakie.Figure()
ax1 = CairoMakie.Axis(fig[1,1], xticks = (1:7, grades), title = "Pore and Particle Size")

barplot!(ax1, 1:7,
particles,
dodge = [1,1,1,1,1,1,1], width = 0.5,
)

barplot!(ax1, 1:7,
pores,
dodge = [2,2,2,2,2,2,2], width = 0.5,
)

```

 ![image2026-05-13022952089](https://global.discourse-cdn.com/julialang/original/3X/6/7/6716b29e6868359471ec3f47a86b21175e8dc4e4.png)

---

<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:** [May 13, 2026, 8:58am UTC](https://discourse.julialang.org/t/makie-bar-plots/137098/2 "2026-05-13T08:58:47Z")

</div>

```julia-auto
using CairoMakie

grades = ["ZXF-5Q", "ACF-10Q", "AXF-3Q", "AXF-5Q", "AXM-5Q", "AXZ-5Q", "TM"]
particles = [1.0, 4.9, 4.9, 4.9, 4.9, 4.9, 1.0]
pores = [0.3, 0.8, 0.8, 0.8, 0.8, 0.7, 1.5]

fig = Figure()
ax1 = Axis(
    fig[1, 1],
    xticks = (1:7, grades),
    title = "Pore and Particle Size",
)

# 7 positions, 2 bars per position
x = repeat(1:7, inner = 2) # Int vector, length 14
y = vcat(particles, pores) # Float vector, length 14
dodge = repeat([1, 2], 7) # group ids, length 14
colors = repeat([:steelblue, :goldenrod], 7)

barplot!(ax1, x, y; dodge = dodge, color = colors, width = 0.8)

fig

```

will give you what you’re looking for.

 ![CleanShot 2026-05-13 at 01.54.47](https://global.discourse-cdn.com/julialang/original/3X/4/f/4f7d8422ea75a6f11788eb4e06e3dd8046448a81.png)

A minimum working example would help elucidate how to get from the example to the proposed solution.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [May 13, 2026, 9:58am UTC](https://discourse.julialang.org/t/makie-bar-plots/137098/3 "2026-05-13T09:58:12Z")

</div>

You need to set `ndodge` if the dodge vectors don’t all contain the largest index, because that’s what’s used by default. Barplot 1 sees a dodge group with ndodge=1 which is no dodge. Barplot 2 sees 2 as the highest value so that one’s dodged correctly. AoG sets this stuff based on the categorical scale it determines globally.

---

<div class="post-metadata">

**Author:** ![Mervyn\_Larrier](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mervyn_larrier/32/37709_2.png) [@Mervyn\_Larrier](https://discourse.julialang.org/u/Mervyn_Larrier)\
**Post date:** [May 13, 2026, 4:50pm UTC](https://discourse.julialang.org/t/makie-bar-plots/137098/4 "2026-05-13T16:50:06Z")

</div>

Thank you kindly.
