simplify axes_drawing_info
This commit is contained in:
parent
140afeb53d
commit
05ef841d63
94
src/axes.jl
94
src/axes.jl
@ -637,13 +637,13 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
|
|
||||||
if sp[:framestyle] != :none
|
if sp[:framestyle] != :none
|
||||||
# xaxis
|
# xaxis
|
||||||
|
y1, y2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, ymin) : (ymin, ymax)
|
||||||
|
end
|
||||||
if xaxis[:showaxis]
|
if xaxis[:showaxis]
|
||||||
if sp[:framestyle] != :grid
|
if sp[:framestyle] != :grid
|
||||||
y1, y2 = if sp[:framestyle] in (:origin, :zerolines)
|
|
||||||
0.0, 0.0
|
|
||||||
else
|
|
||||||
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, ymin) : (ymin, ymax)
|
|
||||||
end
|
|
||||||
push!(xaxis_segs, (xmin, y1), (xmax, y1))
|
push!(xaxis_segs, (xmin, y1), (xmax, y1))
|
||||||
# don't show the 0 tick label for the origin framestyle
|
# don't show the 0 tick label for the origin framestyle
|
||||||
if sp[:framestyle] == :origin && !(xticks in (:none, nothing, false)) && length(xticks) > 1
|
if sp[:framestyle] == :origin && !(xticks in (:none, nothing, false)) && length(xticks) > 1
|
||||||
@ -657,54 +657,47 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
f = scalefunc(yaxis[:scale])
|
f = scalefunc(yaxis[:scale])
|
||||||
invf = invscalefunc(yaxis[:scale])
|
invf = invscalefunc(yaxis[:scale])
|
||||||
ticks_in = xaxis[:tick_direction] == :out ? -1 : 1
|
ticks_in = xaxis[:tick_direction] == :out ? -1 : 1
|
||||||
t1 = invf(f(ymin) + 0.015 * (f(ymax) - f(ymin)) * ticks_in)
|
t1 = invf(f(y1) + 0.01 * (f(y2) - f(y1)) * ticks_in)
|
||||||
t2 = invf(f(ymax) - 0.015 * (f(ymax) - f(ymin)) * ticks_in)
|
t2 = invf(f(0) + 0.01 * (f(ymax) - f(ymin)))
|
||||||
t3 = invf(f(0) + 0.015 * (f(ymax) - f(ymin)) * ticks_in)
|
|
||||||
|
|
||||||
for xtick in xticks[1]
|
for xtick in xticks[1]
|
||||||
if xaxis[:showaxis]
|
if xaxis[:showaxis]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
(0, t3)
|
(-t2, t2)
|
||||||
else
|
else
|
||||||
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, t2) : (ymin, t1)
|
(y1, t1)
|
||||||
end
|
end
|
||||||
push!(xtick_segs, (xtick, tick_start), (xtick, tick_stop)) # bottom tick
|
push!(xtick_segs, (xtick, tick_start), (xtick, tick_stop)) # bottom tick
|
||||||
end
|
end
|
||||||
# sp[:draw_axes_border] && push!(xaxis_segs, (xtick, ymax), (xtick, t2)) # top tick
|
# sp[:draw_axes_border] && push!(xaxis_segs, (xtick, ymax), (xtick, t2)) # top tick
|
||||||
xaxis[:grid] && push!(xgrid_segs, (xtick, ymin), (xtick, ymax)) # vertical grid
|
xaxis[:grid] && push!(xgrid_segs, (xtick, ymin), (xtick, ymax)) # vertical grid
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if !(xaxis[:minorticks] in (:none, nothing, false)) || xaxis[:minorgrid]
|
|
||||||
f = scalefunc(yaxis[:scale])
|
|
||||||
invf = invscalefunc(yaxis[:scale])
|
|
||||||
ticks_in = xaxis[:tick_direction] == :out ? -1 : 1
|
|
||||||
t1 = invf(f(ymin) + 0.01 * (f(ymax) - f(ymin)) * ticks_in)
|
|
||||||
t2 = invf(f(ymax) - 0.01 * (f(ymax) - f(ymin)) * ticks_in)
|
|
||||||
t3 = invf(f(0) + 0.01 * (f(ymax) - f(ymin)) * ticks_in)
|
|
||||||
|
|
||||||
for xminortick in xminorticks
|
if !(xaxis[:minorticks] in (:none, nothing, false)) || xaxis[:minorgrid]
|
||||||
if xaxis[:showaxis]
|
for xminortick in xminorticks
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
if xaxis[:showaxis]
|
||||||
(0, t3)
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
else
|
(-t2, t2)
|
||||||
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, t2) : (ymin, t1)
|
else
|
||||||
|
(y1, t1)
|
||||||
|
end
|
||||||
|
push!(xtick_segs, (xminortick, tick_start), (xminortick, tick_stop)) # bottom tick
|
||||||
end
|
end
|
||||||
push!(xtick_segs, (xminortick, tick_start), (xminortick, tick_stop)) # bottom tick
|
# sp[:draw_axes_border] && push!(xaxis_segs, (xtick, ymax), (xtick, t2)) # top tick
|
||||||
|
xaxis[:minorgrid] && push!(xminorgrid_segs, (xminortick, ymin), (xminortick, ymax)) # vertical grid
|
||||||
end
|
end
|
||||||
# sp[:draw_axes_border] && push!(xaxis_segs, (xtick, ymax), (xtick, t2)) # top tick
|
|
||||||
xaxis[:minorgrid] && push!(xminorgrid_segs, (xminortick, ymin), (xminortick, ymax)) # vertical grid
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# yaxis
|
# yaxis
|
||||||
|
x1, x2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, xmin) : (xmin, xmax)
|
||||||
|
end
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
if sp[:framestyle] != :grid
|
if sp[:framestyle] != :grid
|
||||||
x1, x2 = if sp[:framestyle] in (:origin, :zerolines)
|
|
||||||
0.0, 0.0
|
|
||||||
else
|
|
||||||
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, xmin) : (xmin, xmax)
|
|
||||||
end
|
|
||||||
push!(yaxis_segs, (x1, ymin), (x1, ymax))
|
push!(yaxis_segs, (x1, ymin), (x1, ymax))
|
||||||
# don't show the 0 tick label for the origin framestyle
|
# don't show the 0 tick label for the origin framestyle
|
||||||
if sp[:framestyle] == :origin && !(yticks in (:none, nothing,false)) && length(yticks) > 1
|
if sp[:framestyle] == :origin && !(yticks in (:none, nothing,false)) && length(yticks) > 1
|
||||||
@ -718,42 +711,35 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
f = scalefunc(xaxis[:scale])
|
f = scalefunc(xaxis[:scale])
|
||||||
invf = invscalefunc(xaxis[:scale])
|
invf = invscalefunc(xaxis[:scale])
|
||||||
ticks_in = yaxis[:tick_direction] == :out ? -1 : 1
|
ticks_in = yaxis[:tick_direction] == :out ? -1 : 1
|
||||||
t1 = invf(f(xmin) + 0.015 * (f(xmax) - f(xmin)) * ticks_in)
|
t1 = invf(f(x1) + 0.01 * (f(x2) - f(x1)) * ticks_in)
|
||||||
t2 = invf(f(xmax) - 0.015 * (f(xmax) - f(xmin)) * ticks_in)
|
t2 = invf(f(0) + 0.01 * (f(xmax) - f(xmin)))
|
||||||
t3 = invf(f(0) + 0.015 * (f(xmax) - f(xmin)) * ticks_in)
|
|
||||||
|
|
||||||
for ytick in yticks[1]
|
for ytick in yticks[1]
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
(0, t3)
|
(-t2, t2)
|
||||||
else
|
else
|
||||||
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, t2) : (xmin, t1)
|
(x1, t1)
|
||||||
end
|
end
|
||||||
push!(ytick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
|
push!(ytick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
|
||||||
end
|
end
|
||||||
# sp[:draw_axes_border] && push!(yaxis_segs, (xmax, ytick), (t2, ytick)) # right tick
|
# sp[:draw_axes_border] && push!(yaxis_segs, (xmax, ytick), (t2, ytick)) # right tick
|
||||||
yaxis[:grid] && push!(ygrid_segs, (xmin, ytick), (xmax, ytick)) # horizontal grid
|
yaxis[:grid] && push!(ygrid_segs, (xmin, ytick), (xmax, ytick)) # horizontal grid
|
||||||
end
|
end
|
||||||
end
|
|
||||||
if !(yaxis[:minorticks] in (:none, nothing, false)) || yaxis[:minorgrid]
|
|
||||||
f = scalefunc(xaxis[:scale])
|
|
||||||
invf = invscalefunc(xaxis[:scale])
|
|
||||||
ticks_in = yaxis[:tick_direction] == :out ? -1 : 1
|
|
||||||
t1 = invf(f(xmin) + 0.01 * (f(xmax) - f(xmin)) * ticks_in)
|
|
||||||
t2 = invf(f(xmax) - 0.01 * (f(xmax) - f(xmin)) * ticks_in)
|
|
||||||
t3 = invf(f(0) + 0.01 * (f(xmax) - f(xmin)) * ticks_in)
|
|
||||||
|
|
||||||
for ytick in yminorticks
|
if !(yaxis[:minorticks] in (:none, nothing, false)) || yaxis[:minorgrid]
|
||||||
if yaxis[:showaxis]
|
for ytick in yminorticks
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
if yaxis[:showaxis]
|
||||||
(0, t3)
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
else
|
(-t2, t2)
|
||||||
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, t2) : (xmin, t1)
|
else
|
||||||
|
(x1, t1)
|
||||||
|
end
|
||||||
|
push!(ytick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
|
||||||
end
|
end
|
||||||
push!(ytick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
|
# sp[:draw_axes_border] && push!(yaxis_segs, (xmax, ytick), (t2, ytick)) # right tick
|
||||||
|
yaxis[:minorgrid] && push!(yminorgrid_segs, (xmin, ytick), (xmax, ytick)) # horizontal grid
|
||||||
end
|
end
|
||||||
# sp[:draw_axes_border] && push!(yaxis_segs, (xmax, ytick), (t2, ytick)) # right tick
|
|
||||||
yaxis[:minorgrid] && push!(yminorgrid_segs, (xmin, ytick), (xmax, ytick)) # horizontal grid
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user