Merge pull request #2962 from Moelf/master

fix error bars in log scale
This commit is contained in:
Daniel Schwabeneder 2020-09-25 09:47:27 +02:00 committed by GitHub
commit e932c76d93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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