# Bar plot with different baseline for each bar?

`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

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

``````            |x|
|x| |x|
|x| |x|
|x| |x|
|x|
``````

?

One way using post-processing:

``````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))
``````

1 Like

using the transparency parameter

``````using StatsPlots

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

There is an example for that in the documentation Bar plot customizations · Plots

2 Likes

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)`