3131
3232
3333"""
34- stackedhist(hs:AbstractVector{<:Hist1D}; errors=true|:bar|:shade, color=Makie.wong_colors())
34+ stackedhist(hs:AbstractVector{<:Hist1D}; errors=true|:bar|:shade, color=Makie.wong_colors(), gap=-0.01 )
3535
3636Plot a vector of 1D histograms stacked, use `errors` to show or hide error bar in the plot.
3737`errors = true` and `errors = :bar` are equivalent.
@@ -52,14 +52,18 @@ title = "Processes"
5252Legend(fig[1,2], elements, labels, title)
5353fig
5454```
55+
56+ !!! note
57+ The `gap` attribute is used to control the gap between the bars, it is set to `-0.01` by default to supress
58+ artifacts in Cairo backend.
5559"""
5660@recipe (StackedHist) do scene
5761 Attributes (
5862 error_color = (:black , 0.5 ),
5963 color = Makie. wong_colors (),
6064 labels = nothing ,
6165 whiskerwidth = 10 ,
62- gap = 0
66+ gap = - 0.01
6367 )
6468end
6569
@@ -83,19 +87,19 @@ function Makie.plot!(input::StackedHist{<:Tuple{AbstractVector{<:Hist1D}}})
8387 Makie. barplot! (input, xs, ys;
8488 stack = grp,
8589 color = c[grp],
86- gap = 0 ,
90+ gap = input[ :gap ] ,
8791 )
8892
8993 error_color = input[:error_color ]
9094 if error_color ∈ (true , :bar )
9195 errorbars! (input, centers, totals, errs/ 2 , whiskerwidth = input[:whiskerwidth ])
9296 else
9397 crossbar! (input, centers, totals, totals .+ errs/ 2 , totals .- errs/ 2 ;
94- gap = 0 ,
95- width = diff (_e),
96- show_midline = false ,
97- color = error_color
98- )
98+ gap = input[ :gap ] ,
99+ width = diff (_e),
100+ show_midline = false ,
101+ color = error_color
102+ )
99103 end
100104 input
101105end
@@ -111,6 +115,7 @@ Plot a histogram that represents a ratio (i.e. `h = h1/h3`), you can pass `color
111115 Attributes (
112116 errors = true ,
113117 whiskerwidth = 10 ,
118+ color = :black
114119 )
115120end
116121
@@ -119,7 +124,7 @@ function Makie.plot!(input::RatioHist{<:Tuple{<:Hist1D}})
119124 xs = bincenters (hratio)
120125 ys = bincounts (hratio)
121126
122- color = input[:color ][]
127+ color = input[:color ]
123128
124129 scatter! (input, xs, ys; color= color)
125130 if input[:errors ][]
@@ -200,7 +205,6 @@ function Makie.plot!(plot::Hist{<:Tuple{<:Hist1D}})
200205 for key in keys (attributes)
201206 attributes[key] = get (plot. attributes, key, attributes[key])
202207 end
203- attributes[:gap ][] = 0
204208 attributes[:fillto ][] = eps ()
205209 myhist = plot[1 ]
206210 attributes[:width ][] = diff (binedges (myhist[]))
0 commit comments