simplify logic
This commit is contained in:
parent
81a26f4140
commit
ad3b8f96fd
50
src/axes.jl
50
src/axes.jl
@ -592,7 +592,7 @@ function axis_limits(
|
|||||||
sp,
|
sp,
|
||||||
letter,
|
letter,
|
||||||
should_widen = default_should_widen(sp[get_attr_symbol(letter, :axis)]),
|
should_widen = default_should_widen(sp[get_attr_symbol(letter, :axis)]),
|
||||||
consider_aspect = true,
|
consider_aspect = sp[:aspect_ratio] ∉ (:auto, :none),
|
||||||
)
|
)
|
||||||
axis = sp[get_attr_symbol(letter, :axis)]
|
axis = sp[get_attr_symbol(letter, :axis)]
|
||||||
ex = axis[:extrema]
|
ex = axis[:extrema]
|
||||||
@ -638,14 +638,17 @@ function axis_limits(
|
|||||||
amin, amax
|
amin, amax
|
||||||
end
|
end
|
||||||
|
|
||||||
if (
|
if !has_user_lims && consider_aspect
|
||||||
!has_user_lims &&
|
aspect_ratio = sp[:aspect_ratio]
|
||||||
consider_aspect &&
|
aspect_ratio =
|
||||||
letter in (:x, :y) &&
|
isa(aspect_ratio, Number) ? aspect_ratio :
|
||||||
sp[:aspect_ratio] in (:none, :auto)
|
aspect_ratio === :equal ? 1 :
|
||||||
)
|
throw(
|
||||||
if !RecipesPipeline.is3d(:sp)
|
ArgumentError(
|
||||||
aspect_ratio = isa(sp[:aspect_ratio], Number) ? sp[:aspect_ratio] : 1
|
"Unsuppported value $aspect_ratio for keyword `aspect_ratio`.",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
if !RecipesPipeline.is3d(sp)
|
||||||
plot_ratio = height(plotarea(sp)) / width(plotarea(sp))
|
plot_ratio = height(plotarea(sp)) / width(plotarea(sp))
|
||||||
dist = amax - amin
|
dist = amax - amin
|
||||||
|
|
||||||
@ -667,20 +670,21 @@ function axis_limits(
|
|||||||
amax = center + factor * (amax - center)
|
amax = center + factor * (amax - center)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
end
|
# TODO: support arbitrary box ratios
|
||||||
end
|
if aspect_ratio == 1
|
||||||
if RecipesPipeline.is3d(:sp) && consider_aspect == true
|
x12, y12, z12 = extrema(sp, :x), extrema(sp, :y), extrema(sp, :z)
|
||||||
x12, y12, z12 = extrema(sp, :x), extrema(sp, :y), extrema(sp, :z)
|
d = maximum((x12[2] - x12[1], y12[2] - y12[1], z12[2] - z12[1])) / 2
|
||||||
d = maximum((x12[2] - x12[1], y12[2] - y12[1], z12[2] - z12[1])) / 2
|
amin, amax = if letter == :x
|
||||||
amin, amax = if letter == :x
|
xm = mean(x12)
|
||||||
xm = mean(x12)
|
xm - d, xm + d
|
||||||
xm-d, xm+d
|
elseif letter == :y
|
||||||
elseif letter == :y
|
ym = mean(y12)
|
||||||
ym = mean(y12)
|
ym - d, ym + d
|
||||||
ym-d, ym+d
|
elseif letter == :z
|
||||||
elseif letter ==:z
|
zm = mean(z12)
|
||||||
zm = mean(z12)
|
zm - d, zm + d
|
||||||
zm-d, zm+d
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return amin, amax
|
return amin, amax
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user