FHist.jl icon indicating copy to clipboard operation
FHist.jl copied to clipboard

Default errors for bins with negative content

Open mmikhasenko opened this issue 1 year ago • 3 comments
trafficstars

Breaks with trying to plot the histogram with negative bin content.

Random.seed!(123)
h0 = Hist1D(rand(100); binedges=range(0,1,10))
h0.bincounts .-= mean(h0.bincounts)
plot(h0)

throws,

DomainError with -1.4545795461603218e29:

sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)).

Stack trace
Here is what happened, the most recent locations are first:

throw_complex_domainerror(f::Symbol, x::Float64) @ [math.jl:33](https://github.com/JuliaLang/julia/tree/8f5b7ca12ad48c6d740e058312fc8cf2bbe67848/base/math.jl#L32)
sqrt @ math.jl:608
|> @ operators.jl:926
std(h::FHist.Hist1D{Float64}) @ hist1d.jl:160
macro expansion @ FHistPlotsExt.jl:11
apply_recipe(plotattributes::AbstractDict{Symbol, Any}, h::FHist.Hist1D) @ RecipesBase.jl:300
_process_userrecipes!(plt::Any, plotattributes::Any, args::Any) @ user_recipe.jl:38
recipe_pipeline!(plt::Any, plotattributes::Any, args::Any) @ RecipesPipeline.jl:72
_plot!(plt::Plots.Plot, plotattributes::Any, args::Any) @ plot.jl:223
plot(args::Any; kw...) @ plot.jl:102
plot @ plot.jl:93

mmikhasenko avatar Oct 28 '24 13:10 mmikhasenko