diff --git a/src/axes.jl b/src/axes.jl index 4288cde3..1a0ffcc2 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -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 diff --git a/src/recipes.jl b/src/recipes.jl index bae34819..3f6f2339 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -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)