# Bar plot with different baseline for each bar?

**URL:** <https://discourse.julialang.org/t/bar-plot-with-different-baseline-for-each-bar/81779>\
**Category:** General Usage\
**Tags:** plots\
**Created:** [May 27, 2022, 12:08pm UTC](https://discourse.julialang.org/t/bar-plot-with-different-baseline-for-each-bar/81779 "2022-05-27T12:08:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxkapur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxkapur/32/21208_2.png) [@maxkapur](https://discourse.julialang.org/u/maxkapur)\
**Post date:** [May 27, 2022, 12:08pm UTC](https://discourse.julialang.org/t/bar-plot-with-different-baseline-for-each-bar/81779/1 "2022-05-27T12:08:02Z")

</div>

`using Plots; bar(1:4)` gets you 4 bars, each with their “base” at y = 0, and the $i$th bar has height i. Schematically, that’s

```julia
            |x| 
        |x| |x| 
    |x| |x| |x| 
|x| |x| |x| |x|

```

Is there a simple way to change the location of the “base” of the bar, too? For example, to produce a barplot like

```julia
            |x|
        |x| |x|
    |x| |x| 
|x| |x|
|x| 

```

?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 27, 2022, 12:51pm UTC](https://discourse.julialang.org/t/bar-plot-with-different-baseline-for-each-bar/81779/2 "2022-05-27T12:51:26Z")

</div>

One way using post-processing:

```julia
using Plots
n = 4
p = bar(1:n)
for i in 1:n
    p.series_list[1][:y][6*i-5:min(6*i,6*n-1)] .+= 0.5*(i-1)
end
plot(p, ylims=(-0.1, 6))

```

 ![Plots_bar_plot_change_base](https://global.discourse-cdn.com/julialang/original/3X/7/9/7946ab7676c0e3b2309ba865fc1f61cf86c712aa.png)

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [May 27, 2022, 10:14pm UTC](https://discourse.julialang.org/t/bar-plot-with-different-baseline-for-each-bar/81779/3 "2022-05-27T22:14:42Z")

</div>

using the transparency parameter

```julia
using StatsPlots

groupedbar([[1:4...] [0.3:0.5:1.8...]],
            bar_position = :stack,
            alpha=[1 0],
            legend = false)

```

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [May 30, 2022, 6:13pm UTC](https://discourse.julialang.org/t/bar-plot-with-different-baseline-for-each-bar/81779/4 "2022-05-30T18:13:05Z")

</div>

There is an example for that in the documentation [Bar plot customizations · Plots](https://docs.juliaplots.org/stable/gallery/gr/generated/gr-ref56/#gr_demo_56)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 30, 2022, 9:35pm UTC](https://discourse.julialang.org/t/bar-plot-with-different-baseline-for-each-bar/81779/5 "2022-05-30T21:35:00Z")

</div>

Hi Simon, if I am not mistaken the `plot` argument `fillto` moves the baseline but not the topline. This means that the bars get truncated or extended, but not really shifted up or down. For example, compare ` bar(1:4, fillto = 0:0.5:1.5)` with `bar(1:4)`
