Merge 074a4002c00610834de1a234c60f82352a444307 into 5ddcdef1b4ff10471d4b9037834b48bee734b45f

This commit is contained in:
Michael Krabbe Borregaard 2017-10-28 14:29:24 +00:00 committed by GitHub
commit ef3e7eb03d
2 changed files with 11 additions and 6 deletions

View File

@ -385,18 +385,20 @@ end
# -------------------------------------------------------------------------
# push the limits out slightly
function widen(lmin, lmax)
span = lmax - lmin
function widen(lmin, lmax, scale)
sf = scalefunc(scale)
isf = invscalefunc(scale)
span = sf(lmax) - sf(lmin)
# eps = NaNMath.max(1e-16, min(1e-2span, 1e-10))
eps = NaNMath.max(1e-16, 0.03span)
lmin-eps, lmax+eps
isf(lmin-eps), isf(lmax+eps)
end
# figure out if widening is a good idea. if there's a scale set it's too tricky,
# so lazy out and don't widen
function default_should_widen(axis::Axis)
should_widen = false
if axis[:scale] == :identity && !is_2tuple(axis[:lims])
if (!(axis[:scale] in _logScales && axis[:extrema].emin <= 0)) && !is_2tuple(axis[:lims])
for sp in axis.sps
for series in series_list(sp)
if series.d[:seriestype] in (:scatter,) || series.d[:markershape] != :none
@ -427,8 +429,9 @@ function axis_limits(axis::Axis, should_widen::Bool = default_should_widen(axis)
if !isfinite(amin) && !isfinite(amax)
amin, amax = 0.0, 1.0
end
if should_widen
widen(amin, amax)
widen(amin, amax, axis[:scale])
else
amin, amax
end

View File

@ -317,7 +317,9 @@ end
end
# widen limits out a bit
expand_extrema!(axis, widen(ignorenan_extrema(xseg.pts)...))
if !(axis[:scale] in _logScales && extrema(xseg.pts)[1] <= 0)
expand_extrema!(axis, widen(ignorenan_extrema(xseg.pts)..., axis[:scale]))
end
# switch back
if !isvertical(plotattributes)