# "stack order" in Gadfly histogram

**URL:** <https://discourse.julialang.org/t/stack-order-in-gadfly-histogram/82065>\
**Category:** Visualization\
**Tags:** question, plotting, gadfly\
**Created:** [June 1, 2022, 5:03pm UTC](https://discourse.julialang.org/t/stack-order-in-gadfly-histogram/82065 "2022-06-01T17:03:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brinkhuis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brinkhuis/32/18752_2.png) [@Brinkhuis](https://discourse.julialang.org/u/Brinkhuis)\
**Post date:** [June 1, 2022, 5:03pm UTC](https://discourse.julialang.org/t/stack-order-in-gadfly-histogram/82065/1 "2022-06-01T17:03:23Z")

</div>

When plotting a “stacked histogram”, I would like the “stack order” to be the same as the legend order - `Fair` (first / bottom) and `Ideal` (last / top) - so that the colors are in order from light to dark. Like in [this](https://seaborn.pydata.org/examples/histogram_stacked.html) example.

Any idea how to do that? My code so far:

```julia
using CSV, DataFrames, Gadfly

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

palette = ["#9D95C2", "#B4ADCF", "#C9C4DB", "#DFDCE9", "#F5F3F4"]

plot(
    diamonds, 
    x = :price, 
    color = :cut, 
    Geom.histogram(bincount=50), 
    Scale.x_log10, 
    Scale.color_discrete_manual(palette..., order = [1, 2, 4, 3, 5]), 
    Theme(
        background_color = "white", 
        bar_highlight = color("black")
    ), 
)

```

 ![Screenshot 2022-06-01 at 19.01.59](https://global.discourse-cdn.com/julialang/original/3X/7/6/76cb6102699bb06b1553e1fe237bab18d9358e3b.png)
