axis limits = :symmetric (#2600)
* allow axis-lims = :symmetric * remove show * add test
This commit is contained in:
parent
25b57cfb55
commit
6a62d96751
11
src/axes.jl
11
src/axes.jl
@ -533,13 +533,20 @@ function axis_limits(sp, letter, should_widen = default_should_widen(sp[Symbol(l
|
||||
has_user_lims = (isa(lims, Tuple) || isa(lims, AVec)) && length(lims) == 2
|
||||
if has_user_lims
|
||||
lmin, lmax = lims
|
||||
if lmin != :auto && isfinite(lmin)
|
||||
if lmin == :auto
|
||||
elseif isfinite(lmin)
|
||||
amin = lmin
|
||||
end
|
||||
if lmax != :auto && isfinite(lmax)
|
||||
if lmax == :auto
|
||||
elseif isfinite(lmax)
|
||||
amax = lmax
|
||||
end
|
||||
end
|
||||
if lims == :symmetric
|
||||
aval = max(abs(amin), abs(amax))
|
||||
amin = -aval
|
||||
amax = aval
|
||||
end
|
||||
if amax <= amin && isfinite(amin)
|
||||
amax = amin + 1.0
|
||||
end
|
||||
|
||||
@ -31,3 +31,8 @@ end
|
||||
@test xticks(p) == yticks(p) == zticks(p) == [ticks1, ticks2]
|
||||
@test xticks(p[1]) == yticks(p[1]) == zticks(p[1]) == ticks1
|
||||
end
|
||||
|
||||
@testset "Axis limits" begin
|
||||
pl = plot(1:5, xlims=:symmetric, widen = false)
|
||||
@test Plots.xlims(pl) == (-5, 5)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user