I would love to have a recipe for Plots.jl that creates a histogram
with xerror of the size of the bin, and yerror according to e.g. sqrt(h.weight).
So, there are two problems:
- x-errors do not show up. The
scatterhistis settingxerrorinscatterbins
Plots.jl/recipes.jl at master · JuliaPlots/Plots.jl · GitHub
However, they do not appear
scatterhist(rand(100)) # does not have x-errors
# but!
h = fit(StatsBase.Histogram, ds)
plot(h, seriestype=:scatterbins) # does have x-errors
- y-errors do not appear, I cannot make the line
yerror := sqrt.(h.weights)work
here is what I tried:
@recipe function f(::Type{Val{:errorhist}}, x, y, z)
h = Plots._make_hist((y,), plotattributes[:bins], normed = plotattributes[:normalize], weights = plotattributes[:weights])
edge = collect(h.edges)
#
x := Plots._bin_centers(edge)
y := h.weights
xerror := diff(edge)/2
yerror := sqrt.(h.weights)
seriestype := :scatter
linewidth := 2
()
end
"""
errorhist
"""
@shorthands errorhist
#
errorhist(rand(1000), bins=100) # empty plot ...
EDIT: the plot was empty because edge = collect(h.edges) suppose to be edge = collect(h.edges[1]). After fixing, the scatter plot appears but without any errorbars.
