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.
Does your code work without the recipe macro? If not, and you have a small number of bins, a bar and scatter plot combination might work. Perhaps like the following:
Sure, I can create a StatsBase.Histogram first and, then, plot using the barplot as you suggest. However, It is not the point. One should be able to say èrrorhist(rand(1000)) and get the right plot.