Gadfly: how to add bar spacing to stacked plot without shifting off center?

I’m having trouble adding bar spacing to a stacked plot, as it is shifting the bars off center.

dfsample = CSV.read("dfsample.csv", DataFrame)
p = plot(dfsample,
    x=:Percent,
    y=:LessonName,
    color=:PassType,
    Geom.bar(orientation = :horizontal),
    Theme(
        #bar_spacing=5mm
    )
)

In this image you can see the DataFrame. The first plot is using the code above. When I add 5mm of bar spacing note how bars are shifted off center (plot 2). Then if I remove the color argument I get the expected behavior of centered bars with 5mm of spacing (plot 3). Any ideas?

1 Like

Same, here with the latest version (v1.3.4) of Gadfly. Maybe open a new issue at Issues · GiovineItalia/Gadfly.jl · GitHub

using CSV, DataFrames, Statistics, Gadfly

download("https://raw.githubusercontent.com/mwaskom/seaborn-data/master/penguins.csv", "penguins.csv")
penguins = DataFrame(CSV.File("penguins.csv"))

set_default_plot_size(16cm, 12cm)

plot(
    combine(groupby(dropmissing(penguins), [:species, :sex]), :body_mass_g .=> mean .=> :body_mass_g),
    x = "species", 
    y = "body_mass_g", 
    color = "sex", 
    Geom.bar(orientation = :vertical),
    Theme(bar_spacing = 15mm, background_color = "white",)
)

plot(
    combine(groupby(dropmissing(penguins), [:species, :sex]), :body_mass_g .=> mean .=> :body_mass_g),
    x = "body_mass_g", 
    y = "species", 
    color = "sex", 
    Geom.bar(orientation = :horizontal),
    Theme(bar_spacing = 15mm, background_color = "white",)
)