diff --git a/src/recipes.jl b/src/recipes.jl index efd825c1..2e7833da 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1101,6 +1101,12 @@ function error_coords(errorbar, errordata, otherdata...) return (ed, od...) end +# clamp non-NaN values in an array to Base.eps(Float64) for log-scale plots +function clamp_to_eps!(ary) + replace!(x -> x <= 0.0 ? Base.eps(Float64) : x, ary) + nothing +end + # we will create a series of path segments, where each point represents one # side of an errorbar @@ -1114,6 +1120,9 @@ end plotattributes[:x], plotattributes[:y], plotattributes[:z] = error_coords(xerr, x, y, z) end + if :xscale ∈ keys(plotattributes) && plotattributes[:xscale] == :log10 + clamp_to_eps!(plotattributes[:x]) + end () end @deps xerror path @@ -1128,6 +1137,9 @@ end plotattributes[:y], plotattributes[:x], plotattributes[:z] = error_coords(yerr, y, x, z) end + if :yscale ∈ keys(plotattributes) && plotattributes[:yscale] == :log10 + clamp_to_eps!(plotattributes[:y]) + end () end @deps yerror path @@ -1140,6 +1152,9 @@ end plotattributes[:z], plotattributes[:x], plotattributes[:y] = error_coords(zerr, z, x, y) end + if :zscale ∈ keys(plotattributes) && plotattributes[:zscale] == :log10 + clamp_to_eps!(plotattributes[:z]) + end () end @deps zerror path