From cbbd4fd02933f05a460d6e8ebcf2619c99e60b5f Mon Sep 17 00:00:00 2001 From: Will Grant Date: Wed, 6 Jun 2018 11:20:05 +1000 Subject: [PATCH] allow automatic widening of the axis limits to the next power of 10 with xlim/ylim = :round --- src/axes.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/axes.jl b/src/axes.jl index c873086e..f32d0ade 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -441,6 +441,13 @@ function default_should_widen(axis::Axis) should_widen end +function round_limits(amin,amax) + scale = 10^(1-round(log10(amax - amin))) + amin = floor(amin*scale)/scale + amax = ceil(amax*scale)/scale + amin, amax +end + # using the axis extrema and limit overrides, return the min/max value for this axis function axis_limits(axis::Axis, should_widen::Bool = default_should_widen(axis)) ex = axis[:extrema] @@ -471,6 +478,8 @@ function axis_limits(axis::Axis, should_widen::Bool = default_should_widen(axis) end elseif should_widen widen(amin, amax) + elseif lims == :round + round_limits(amin,amax) else amin, amax end