allow automatic widening of the axis limits to the next power of 10 with xlim/ylim = :round
This commit is contained in:
parent
f6bc7721a8
commit
cbbd4fd029
@ -441,6 +441,13 @@ function default_should_widen(axis::Axis)
|
|||||||
should_widen
|
should_widen
|
||||||
end
|
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
|
# 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))
|
function axis_limits(axis::Axis, should_widen::Bool = default_should_widen(axis))
|
||||||
ex = axis[:extrema]
|
ex = axis[:extrema]
|
||||||
@ -471,6 +478,8 @@ function axis_limits(axis::Axis, should_widen::Bool = default_should_widen(axis)
|
|||||||
end
|
end
|
||||||
elseif should_widen
|
elseif should_widen
|
||||||
widen(amin, amax)
|
widen(amin, amax)
|
||||||
|
elseif lims == :round
|
||||||
|
round_limits(amin,amax)
|
||||||
else
|
else
|
||||||
amin, amax
|
amin, amax
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user