diff --git a/src/Gnuplot.jl b/src/Gnuplot.jl index 18a8057..7c82e50 100644 --- a/src/Gnuplot.jl +++ b/src/Gnuplot.jl @@ -1853,9 +1853,9 @@ function hist(v::Vector{T}; range=[NaN,NaN], bs=NaN, nbins=0, pad=true) where T end @assert sum(hh.weights) == length(i) x = collect(hh.edges[1]) + binsize = x[2] - x[1] x = (x[1:end-1] .+ x[2:end]) ./ 2 h = hh.weights - binsize = x[2] - x[1] if pad x = [x[1]-binsize, x..., x[end]+binsize] h = [0, h..., 0] diff --git a/test/runtests.jl b/test/runtests.jl index 76a91ed..53fe0fe 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -286,4 +286,7 @@ Gnuplot.quit(:default) Gnuplot.options.dry = true @gp hist(randn(1000)) +# Various hist() corner cases +@gp hist([1,2,3], bs=2) + Gnuplot.quitall()