commit
82479d48b9
346
src/axes.jl
346
src/axes.jl
@ -637,13 +637,13 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
|
|
||||||
if sp[:framestyle] != :none
|
if sp[:framestyle] != :none
|
||||||
# xaxis
|
# xaxis
|
||||||
if xaxis[:showaxis]
|
|
||||||
if sp[:framestyle] != :grid
|
|
||||||
y1, y2 = if sp[:framestyle] in (:origin, :zerolines)
|
y1, y2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
0.0, 0.0
|
0.0, 0.0
|
||||||
else
|
else
|
||||||
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, ymin) : (ymin, ymax)
|
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, ymin) : (ymin, ymax)
|
||||||
end
|
end
|
||||||
|
if xaxis[:showaxis]
|
||||||
|
if sp[:framestyle] != :grid
|
||||||
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
|
||||||
@ -656,55 +656,48 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
if !(xaxis[:ticks] in (:none, nothing, false))
|
if !(xaxis[:ticks] in (:none, nothing, false))
|
||||||
f = scalefunc(yaxis[:scale])
|
f = scalefunc(yaxis[:scale])
|
||||||
invf = invscalefunc(yaxis[:scale])
|
invf = invscalefunc(yaxis[:scale])
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.012 * (f(ymax) - f(ymin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
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)
|
t = invf(f(y1) + 0.012 * (f(y2) - f(y1)) * ticks_in)
|
||||||
t2 = invf(f(ymax) - 0.015 * (f(ymax) - f(ymin)) * ticks_in)
|
(y1, t)
|
||||||
t3 = invf(f(0) + 0.015 * (f(ymax) - f(ymin)) * ticks_in)
|
end
|
||||||
|
|
||||||
for xtick in xticks[1]
|
for xtick in xticks[1]
|
||||||
if xaxis[:showaxis]
|
if xaxis[:showaxis]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
|
||||||
(0, t3)
|
|
||||||
else
|
|
||||||
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, t2) : (ymin, t1)
|
|
||||||
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
|
|
||||||
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]
|
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
(0, t3)
|
t = invf(f(0) + 0.006 * (f(ymax) - f(ymin)))
|
||||||
|
(-t, t)
|
||||||
else
|
else
|
||||||
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, t2) : (ymin, t1)
|
t = invf(f(y1) + 0.006 * (f(y2) - f(y1)) * ticks_in)
|
||||||
|
(y1, t)
|
||||||
end
|
end
|
||||||
push!(xtick_segs, (xminortick, tick_start), (xminortick, tick_stop)) # bottom tick
|
for xtick in xminorticks
|
||||||
|
if xaxis[:showaxis]
|
||||||
|
push!(xtick_segs, (xtick, tick_start), (xtick, tick_stop)) # bottom tick
|
||||||
|
end
|
||||||
|
xaxis[:minorgrid] && push!(xminorgrid_segs, (xtick, ymin), (xtick, 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
|
||||||
if yaxis[:showaxis]
|
|
||||||
if sp[:framestyle] != :grid
|
|
||||||
x1, x2 = if sp[:framestyle] in (:origin, :zerolines)
|
x1, x2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
0.0, 0.0
|
0.0, 0.0
|
||||||
else
|
else
|
||||||
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, xmin) : (xmin, xmax)
|
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, xmin) : (xmin, xmax)
|
||||||
end
|
end
|
||||||
|
if yaxis[:showaxis]
|
||||||
|
if sp[:framestyle] != :grid
|
||||||
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
|
||||||
@ -717,46 +710,297 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
if !(yaxis[:ticks] in (:none, nothing, false))
|
if !(yaxis[:ticks] in (:none, nothing, false))
|
||||||
f = scalefunc(xaxis[:scale])
|
f = scalefunc(xaxis[:scale])
|
||||||
invf = invscalefunc(xaxis[:scale])
|
invf = invscalefunc(xaxis[:scale])
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.012 * (f(xmax) - f(xmin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
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)
|
t = invf(f(x1) + 0.012 * (f(x2) - f(x1)) * ticks_in)
|
||||||
t2 = invf(f(xmax) - 0.015 * (f(xmax) - f(xmin)) * ticks_in)
|
(x1, t)
|
||||||
t3 = invf(f(0) + 0.015 * (f(xmax) - f(xmin)) * ticks_in)
|
end
|
||||||
|
|
||||||
for ytick in yticks[1]
|
for ytick in yticks[1]
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
|
||||||
(0, t3)
|
|
||||||
else
|
|
||||||
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, t2) : (xmin, t1)
|
|
||||||
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
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
if !(yaxis[:minorticks] in (:none, nothing, false)) || yaxis[:minorgrid]
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.006 * (f(xmax) - f(xmin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
|
t = invf(f(x1) + 0.006 * (f(x2) - f(x1)) * ticks_in)
|
||||||
|
(x1, t)
|
||||||
|
end
|
||||||
for ytick in yminorticks
|
for ytick in yminorticks
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
|
||||||
(0, t3)
|
|
||||||
else
|
|
||||||
xor(yaxis[:mirror], xaxis[:flip]) ? (xmax, t2) : (xmin, t1)
|
|
||||||
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
|
|
||||||
yaxis[:minorgrid] && push!(yminorgrid_segs, (xmin, ytick), (xmax, ytick)) # horizontal grid
|
yaxis[:minorgrid] && push!(yminorgrid_segs, (xmin, ytick), (xmax, ytick)) # horizontal grid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
xticks, yticks, xaxis_segs, yaxis_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs
|
xticks, yticks, xaxis_segs, yaxis_segs, xtick_segs, ytick_segs, xgrid_segs, ygrid_segs, xminorgrid_segs, yminorgrid_segs, xborder_segs, yborder_segs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function axis_drawing_info_3d(sp::Subplot)
|
||||||
|
xaxis, yaxis, zaxis = sp[:xaxis], sp[:yaxis], sp[:zaxis]
|
||||||
|
xmin, xmax = axis_limits(sp, :x)
|
||||||
|
ymin, ymax = axis_limits(sp, :y)
|
||||||
|
zmin, zmax = axis_limits(sp, :z)
|
||||||
|
xticks = get_ticks(sp, xaxis)
|
||||||
|
yticks = get_ticks(sp, yaxis)
|
||||||
|
zticks = get_ticks(sp, zaxis)
|
||||||
|
xminorticks = get_minor_ticks(sp, xaxis, xticks)
|
||||||
|
yminorticks = get_minor_ticks(sp, yaxis, yticks)
|
||||||
|
zminorticks = get_minor_ticks(sp, zaxis, zticks)
|
||||||
|
xaxis_segs = Segments(3)
|
||||||
|
yaxis_segs = Segments(3)
|
||||||
|
zaxis_segs = Segments(3)
|
||||||
|
xtick_segs = Segments(3)
|
||||||
|
ytick_segs = Segments(3)
|
||||||
|
ztick_segs = Segments(3)
|
||||||
|
xgrid_segs = Segments(3)
|
||||||
|
ygrid_segs = Segments(3)
|
||||||
|
zgrid_segs = Segments(3)
|
||||||
|
xminorgrid_segs = Segments(3)
|
||||||
|
yminorgrid_segs = Segments(3)
|
||||||
|
zminorgrid_segs = Segments(3)
|
||||||
|
xborder_segs = Segments(3)
|
||||||
|
yborder_segs = Segments(3)
|
||||||
|
zborder_segs = Segments(3)
|
||||||
|
|
||||||
|
if sp[:framestyle] != :none
|
||||||
|
|
||||||
|
# xaxis
|
||||||
|
y1, y2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(xaxis[:mirror], yaxis[:flip]) ? (ymax, ymin) : (ymin, ymax)
|
||||||
|
end
|
||||||
|
z1, z2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(xaxis[:mirror], zaxis[:flip]) ? (zmax, zmin) : (zmin, zmax)
|
||||||
|
end
|
||||||
|
if xaxis[:showaxis]
|
||||||
|
if sp[:framestyle] != :grid
|
||||||
|
push!(xaxis_segs, (xmin, y1, z1), (xmax, y1, z1))
|
||||||
|
# don't show the 0 tick label for the origin framestyle
|
||||||
|
if sp[:framestyle] == :origin && !(xticks in (:none, nothing, false)) && length(xticks) > 1
|
||||||
|
showticks = xticks[1] .!= 0
|
||||||
|
xticks = (xticks[1][showticks], xticks[2][showticks])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sp[:framestyle] in (:semi, :box) && push!(xborder_segs, (xmin, y2, z2), (xmax, y2, z2)) # top spine
|
||||||
|
end
|
||||||
|
if !(xaxis[:ticks] in (:none, nothing, false))
|
||||||
|
f = scalefunc(yaxis[:scale])
|
||||||
|
invf = invscalefunc(yaxis[:scale])
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.012 * (f(ymax) - f(ymin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
|
ticks_in = xaxis[:tick_direction] == :out ? -1 : 1
|
||||||
|
t = invf(f(y1) + 0.012 * (f(y2) - f(y1)) * ticks_in)
|
||||||
|
(y1, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
for xtick in xticks[1]
|
||||||
|
if xaxis[:showaxis]
|
||||||
|
push!(xtick_segs, (xtick, tick_start, z1), (xtick, tick_stop, z1)) # bottom tick
|
||||||
|
end
|
||||||
|
if xaxis[:grid]
|
||||||
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
push!(xgrid_segs, (xtick, ymin, 0.0), (xtick, ymax, 0.0))
|
||||||
|
push!(xgrid_segs, (xtick, 0.0, zmin), (xtick, 0.0, zmax))
|
||||||
|
else
|
||||||
|
push!(xgrid_segs, (xtick, y1, z1), (xtick, y2, z1))
|
||||||
|
push!(xgrid_segs, (xtick, y2, z1), (xtick, y2, z2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(xaxis[:minorticks] in (:none, nothing, false)) || xaxis[:minorgrid]
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.006 * (f(ymax) - f(ymin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
|
t = invf(f(y1) + 0.006 * (f(y2) - f(y1)) * ticks_in)
|
||||||
|
(y1, t)
|
||||||
|
end
|
||||||
|
for xtick in xminorticks
|
||||||
|
if xaxis[:showaxis]
|
||||||
|
push!(xtick_segs, (xtick, tick_start, z1), (xtick, tick_stop, z1)) # bottom tick
|
||||||
|
end
|
||||||
|
if xaxis[:minorgrid]
|
||||||
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
push!(xminorgrid_segs, (xtick, ymin, 0.0), (xtick, ymax, 0.0))
|
||||||
|
push!(xminorgrid_segs, (xtick, 0.0, zmin), (xtick, 0.0, zmax))
|
||||||
|
else
|
||||||
|
push!(xminorgrid_segs, (xtick, y1, z1), (xtick, y2, z1))
|
||||||
|
push!(xminorgrid_segs, (xtick, y2, z1), (xtick, y2, z2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# yaxis
|
||||||
|
x1, x2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(yaxis[:mirror], xaxis[:flip]) ? (xmin, xmax) : (xmax, xmin)
|
||||||
|
end
|
||||||
|
z1, z2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(yaxis[:mirror], zaxis[:flip]) ? (zmax, zmin) : (zmin, zmax)
|
||||||
|
end
|
||||||
|
if yaxis[:showaxis]
|
||||||
|
if sp[:framestyle] != :grid
|
||||||
|
push!(yaxis_segs, (x1, ymin, z1), (x1, ymax, z1))
|
||||||
|
# don't show the 0 tick label for the origin framestyle
|
||||||
|
if sp[:framestyle] == :origin && !(yticks in (:none, nothing,false)) && length(yticks) > 1
|
||||||
|
showticks = yticks[1] .!= 0
|
||||||
|
yticks = (yticks[1][showticks], yticks[2][showticks])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sp[:framestyle] in (:semi, :box) && push!(yborder_segs, (x2, ymin, z2), (x2, ymax, z2)) # right spine
|
||||||
|
end
|
||||||
|
if !(yaxis[:ticks] in (:none, nothing, false))
|
||||||
|
f = scalefunc(xaxis[:scale])
|
||||||
|
invf = invscalefunc(xaxis[:scale])
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.012 * (f(xmax) - f(xmin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
|
ticks_in = yaxis[:tick_direction] == :out ? -1 : 1
|
||||||
|
t = invf(f(x1) + 0.012 * (f(x2) - f(x1)) * ticks_in)
|
||||||
|
(x1, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
for ytick in yticks[1]
|
||||||
|
if yaxis[:showaxis]
|
||||||
|
push!(ytick_segs, (tick_start, ytick, z1), (tick_stop, ytick, z1)) # left tick
|
||||||
|
end
|
||||||
|
if yaxis[:grid]
|
||||||
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
push!(ygrid_segs, (xmin, ytick, 0.0), (xmax, ytick, 0.0))
|
||||||
|
push!(ygrid_segs, (0.0, ytick, zmin), (0.0, ytick, zmax))
|
||||||
|
else
|
||||||
|
push!(ygrid_segs, (x1, ytick, z1), (x2, ytick, z1))
|
||||||
|
push!(ygrid_segs, (x2, ytick, z1), (x2, ytick, z2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(yaxis[:minorticks] in (:none, nothing, false)) || yaxis[:minorgrid]
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.006 * (f(xmax) - f(xmin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
|
t = invf(f(x1) + 0.006 * (f(x2) - f(x1)) * ticks_in)
|
||||||
|
(x1, t)
|
||||||
|
end
|
||||||
|
for ytick in yminorticks
|
||||||
|
if yaxis[:showaxis]
|
||||||
|
push!(ytick_segs, (tick_start, ytick, z1), (tick_stop, ytick, z1)) # left tick
|
||||||
|
end
|
||||||
|
if yaxis[:minorgrid]
|
||||||
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
push!(yminorgrid_segs, (xmin, ytick, 0.0), (xmax, ytick, 0.0))
|
||||||
|
push!(yminorgrid_segs, (0.0, ytick, zmin), (0.0, ytick, zmax))
|
||||||
|
else
|
||||||
|
push!(yminorgrid_segs, (x1, ytick, z1), (x2, ytick, z1))
|
||||||
|
push!(yminorgrid_segs, (x2, ytick, z1), (x2, ytick, z2))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# zaxis
|
||||||
|
x1, x2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(zaxis[:mirror], xaxis[:flip]) ? (xmax, xmin) : (xmin, xmax)
|
||||||
|
end
|
||||||
|
y1, y2 = if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
0.0, 0.0
|
||||||
|
else
|
||||||
|
xor(zaxis[:mirror], yaxis[:flip]) ? (ymax, ymin) : (ymin, ymax)
|
||||||
|
end
|
||||||
|
if zaxis[:showaxis]
|
||||||
|
if sp[:framestyle] != :grid
|
||||||
|
push!(zaxis_segs, (x1, y1, zmin), (x1, y1, zmax))
|
||||||
|
# don't show the 0 tick label for the origin framestyle
|
||||||
|
if sp[:framestyle] == :origin && !(zticks in (:none, nothing,false)) && length(zticks) > 1
|
||||||
|
showticks = zticks[1] .!= 0
|
||||||
|
zticks = (zticks[1][showticks], zticks[2][showticks])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sp[:framestyle] in (:semi, :box) && push!(zborder_segs, (x2, y2, zmin), (x2, y2, zmax))
|
||||||
|
end
|
||||||
|
if !(zaxis[:ticks] in (:none, nothing, false))
|
||||||
|
f = scalefunc(xaxis[:scale])
|
||||||
|
invf = invscalefunc(xaxis[:scale])
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.012 * (f(ymax) - f(ymin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
|
ticks_in = zaxis[:tick_direction] == :out ? -1 : 1
|
||||||
|
t = invf(f(y1) + 0.012 * (f(y2) - f(y1)) * ticks_in)
|
||||||
|
(y1, t)
|
||||||
|
end
|
||||||
|
|
||||||
|
for ztick in zticks[1]
|
||||||
|
if zaxis[:showaxis]
|
||||||
|
push!(ztick_segs, (x1, tick_start, ztick), (x1, tick_stop, ztick)) # left tick
|
||||||
|
end
|
||||||
|
if zaxis[:grid]
|
||||||
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
push!(zgrid_segs, (xmin, 0.0, ztick), (xmax, 0.0, ztick))
|
||||||
|
push!(ygrid_segs, (0.0, ymin, ztick), (0.0, ymax, ztick))
|
||||||
|
else
|
||||||
|
push!(ygrid_segs, (x1, y1, ztick), (x1, y2, ztick))
|
||||||
|
push!(ygrid_segs, (x1, y2, ztick), (x2, y2, ztick))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(zaxis[:minorticks] in (:none, nothing, false)) || zaxis[:minorgrid]
|
||||||
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
|
t = invf(f(0) + 0.006 * (f(ymax) - f(ymin)))
|
||||||
|
(-t, t)
|
||||||
|
else
|
||||||
|
t = invf(f(y1) + 0.006 * (f(y2) - f(y1)) * ticks_in)
|
||||||
|
(y1, t)
|
||||||
|
end
|
||||||
|
for ztick in zminorticks
|
||||||
|
if zaxis[:showaxis]
|
||||||
|
push!(ztick_segs, (x1, tick_start, ztick), (x1, tick_stop, ztick)) # left tick
|
||||||
|
end
|
||||||
|
if zaxis[:minorgrid]
|
||||||
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
|
push!(zminorgrid_segs, (xmin, 0.0, ztick), (xmax, 0.0, ztick))
|
||||||
|
push!(zminorgrid_segs, (0.0, ymin, ztick), (0.0, ymax, ztick))
|
||||||
|
else
|
||||||
|
push!(zminorgrid_segs, (x1, y1, ztick), (x1, y2, ztick))
|
||||||
|
push!(zminorgrid_segs, (x1, y2, ztick), (x2, y2, ztick))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
xticks, yticks, zticks, xaxis_segs, yaxis_segs, zaxis_segs, xtick_segs, ytick_segs, ztick_segs, xgrid_segs, ygrid_segs, zgrid_segs, xminorgrid_segs, yminorgrid_segs, zminorgrid_segs, xborder_segs, yborder_segs, zborder_segs
|
||||||
|
end
|
||||||
|
|||||||
@ -155,6 +155,48 @@ function gr_polyline(x, y, func = GR.polyline; arrowside = :none, arrowstyle = :
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function gr_polyline3d(x, y, z, func = GR.polyline3d; arrowside = :none, arrowstyle = :simple)
|
||||||
|
iend = 0
|
||||||
|
n = length(x)
|
||||||
|
while iend < n-1
|
||||||
|
# set istart to the first index that is finite
|
||||||
|
istart = -1
|
||||||
|
for j = iend+1:n
|
||||||
|
if isfinite(x[j]) && isfinite(y[j]) && isfinite(z[j])
|
||||||
|
istart = j
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if istart > 0
|
||||||
|
# iend is the last finite index
|
||||||
|
iend = -1
|
||||||
|
for j = istart+1:n
|
||||||
|
if isfinite(x[j]) && isfinite(y[j]) && isfinite(z[j])
|
||||||
|
iend = j
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# if we found a start and end, draw the line segment, otherwise we're done
|
||||||
|
if istart > 0 && iend > 0
|
||||||
|
func(x[istart:iend], y[istart:iend], z[istart:iend])
|
||||||
|
if arrowside in (:head,:both)
|
||||||
|
gr_set_arrowstyle(arrowstyle)
|
||||||
|
GR.drawarrow(x[iend-1], y[iend-1], z[iend-1], x[iend], y[iend], z[iend])
|
||||||
|
end
|
||||||
|
if arrowside in (:tail,:both)
|
||||||
|
gr_set_arrowstyle(arrowstyle)
|
||||||
|
GR.drawarrow(x[istart+1], y[istart+1], z[istart+1], x[istart], y[istart], z[istart])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
gr_inqtext(x, y, s::Symbol) = gr_inqtext(x, y, string(s))
|
gr_inqtext(x, y, s::Symbol) = gr_inqtext(x, y, string(s))
|
||||||
|
|
||||||
function gr_inqtext(x, y, s)
|
function gr_inqtext(x, y, s)
|
||||||
@ -249,18 +291,6 @@ gr_y_axislims(sp::Subplot) = axis_limits(sp, :y)
|
|||||||
gr_z_axislims(sp::Subplot) = axis_limits(sp, :z)
|
gr_z_axislims(sp::Subplot) = axis_limits(sp, :z)
|
||||||
gr_xy_axislims(sp::Subplot) = gr_x_axislims(sp)..., gr_y_axislims(sp)...
|
gr_xy_axislims(sp::Subplot) = gr_x_axislims(sp)..., gr_y_axislims(sp)...
|
||||||
|
|
||||||
function gr_lims(sp::Subplot, axis::Axis, adjust::Bool, expand = nothing)
|
|
||||||
if expand !== nothing
|
|
||||||
expand_extrema!(axis, expand)
|
|
||||||
end
|
|
||||||
lims = axis_limits(sp, axis[:letter])
|
|
||||||
if adjust
|
|
||||||
GR.adjustrange(lims...)
|
|
||||||
else
|
|
||||||
lims
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function gr_fill_viewport(vp::AVec{Float64}, c)
|
function gr_fill_viewport(vp::AVec{Float64}, c)
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
@ -370,6 +400,12 @@ function gr_nans_to_infs!(z)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function gr_w3tondc(x, y, z)
|
||||||
|
xw, yw, zw = GR.wc3towc(x, y, z)
|
||||||
|
x, y = GR.wctondc(xw, yw)
|
||||||
|
return x, y
|
||||||
|
end
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
# viewport plot area
|
# viewport plot area
|
||||||
|
|
||||||
@ -388,16 +424,8 @@ function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, vi
|
|||||||
viewport[2] = viewport_canvas[2] * (right(bb) / w)
|
viewport[2] = viewport_canvas[2] * (right(bb) / w)
|
||||||
viewport[3] = viewport_canvas[4] * (1.0 - bottom(bb) / h)
|
viewport[3] = viewport_canvas[4] * (1.0 - bottom(bb) / h)
|
||||||
viewport[4] = viewport_canvas[4] * (1.0 - top(bb) / h)
|
viewport[4] = viewport_canvas[4] * (1.0 - top(bb) / h)
|
||||||
if is3d(sp)
|
|
||||||
vp = viewport[:]
|
|
||||||
extent = min(vp[2] - vp[1], vp[4] - vp[3])
|
|
||||||
viewport[1] = 0.5 * (vp[1] + vp[2] - extent)
|
|
||||||
viewport[2] = 0.5 * (vp[1] + vp[2] + extent)
|
|
||||||
viewport[3] = 0.5 * (vp[3] + vp[4] - extent)
|
|
||||||
viewport[4] = 0.5 * (vp[3] + vp[4] + extent)
|
|
||||||
end
|
|
||||||
if hascolorbar(sp)
|
if hascolorbar(sp)
|
||||||
viewport[2] -= gr_colorbar_ratio
|
viewport[2] -= gr_colorbar_ratio * (1 + is3d(sp) / 2)
|
||||||
end
|
end
|
||||||
viewport
|
viewport
|
||||||
end
|
end
|
||||||
@ -567,13 +595,13 @@ function gr_legend_pos(sp::Subplot, w, h)
|
|||||||
if occursin("right", str)
|
if occursin("right", str)
|
||||||
if occursin("outer", str)
|
if occursin("outer", str)
|
||||||
# As per https://github.com/jheinen/GR.jl/blob/master/src/jlgr.jl#L525
|
# As per https://github.com/jheinen/GR.jl/blob/master/src/jlgr.jl#L525
|
||||||
xpos = viewport_plotarea[2] + 0.11 + ymirror * gr_yaxis_width(sp)
|
xpos = viewport_plotarea[2] + 0.11 + ymirror * gr_axis_width(sp, sp[:yaxis])
|
||||||
else
|
else
|
||||||
xpos = viewport_plotarea[2] - 0.05 - w
|
xpos = viewport_plotarea[2] - 0.05 - w
|
||||||
end
|
end
|
||||||
elseif occursin("left", str)
|
elseif occursin("left", str)
|
||||||
if occursin("outer", str)
|
if occursin("outer", str)
|
||||||
xpos = viewport_plotarea[1] - 0.05 - w - !ymirror * gr_yaxis_width(sp)
|
xpos = viewport_plotarea[1] - 0.05 - w - !ymirror * gr_axis_width(sp, sp[:yaxis])
|
||||||
else
|
else
|
||||||
xpos = viewport_plotarea[1] + 0.11
|
xpos = viewport_plotarea[1] + 0.11
|
||||||
end
|
end
|
||||||
@ -582,13 +610,13 @@ function gr_legend_pos(sp::Subplot, w, h)
|
|||||||
end
|
end
|
||||||
if occursin("top", str)
|
if occursin("top", str)
|
||||||
if s == :outertop
|
if s == :outertop
|
||||||
ypos = viewport_plotarea[4] + 0.02 + h + xmirror * gr_xaxis_height(sp)
|
ypos = viewport_plotarea[4] + 0.02 + h + xmirror * gr_axis_height(sp, sp[:xaxis])
|
||||||
else
|
else
|
||||||
ypos = viewport_plotarea[4] - 0.06
|
ypos = viewport_plotarea[4] - 0.06
|
||||||
end
|
end
|
||||||
elseif occursin("bottom", str)
|
elseif occursin("bottom", str)
|
||||||
if s == :outerbottom
|
if s == :outerbottom
|
||||||
ypos = viewport_plotarea[3] - 0.05 - !xmirror * gr_xaxis_height(sp)
|
ypos = viewport_plotarea[3] - 0.05 - !xmirror * gr_axis_height(sp, sp[:xaxis])
|
||||||
else
|
else
|
||||||
ypos = viewport_plotarea[3] + h + 0.06
|
ypos = viewport_plotarea[3] + h + 0.06
|
||||||
end
|
end
|
||||||
@ -747,26 +775,24 @@ function gr_get_ticks_size(ticks, rot)
|
|||||||
return w, h
|
return w, h
|
||||||
end
|
end
|
||||||
|
|
||||||
function gr_xaxis_height(sp)
|
function gr_axis_height(sp, axis)
|
||||||
xaxis = sp[:xaxis]
|
ticks = get_ticks(sp, axis)
|
||||||
xticks, yticks = axis_drawing_info(sp)[1:2]
|
gr_set_font(tickfont(axis))
|
||||||
gr_set_font(tickfont(xaxis))
|
h = (ticks in (nothing, false, :none) ? 0 : last(gr_get_ticks_size(ticks, axis[:rotation])))
|
||||||
h = (xticks in (nothing, false, :none) ? 0 : last(gr_get_ticks_size(xticks, xaxis[:rotation])))
|
if axis[:guide] != ""
|
||||||
if xaxis[:guide] != ""
|
gr_set_font(guidefont(axis))
|
||||||
gr_set_font(guidefont(xaxis))
|
h += last(gr_text_size(axis[:guide]))
|
||||||
h += last(gr_text_size(xaxis[:guide]))
|
|
||||||
end
|
end
|
||||||
return h
|
return h
|
||||||
end
|
end
|
||||||
|
|
||||||
function gr_yaxis_width(sp)
|
function gr_axis_width(sp, axis)
|
||||||
yaxis = sp[:yaxis]
|
ticks = get_ticks(sp, axis)
|
||||||
xticks, yticks = axis_drawing_info(sp)[1:2]
|
gr_set_font(tickfont(axis))
|
||||||
gr_set_font(tickfont(yaxis))
|
w = (ticks in (nothing, false, :none) ? 0 : first(gr_get_ticks_size(ticks, axis[:rotation])))
|
||||||
w = (xticks in (nothing, false, :none) ? 0 : first(gr_get_ticks_size(yticks, yaxis[:rotation])))
|
if axis[:guide] != ""
|
||||||
if yaxis[:guide] != ""
|
gr_set_font(guidefont(axis))
|
||||||
gr_set_font(guidefont(yaxis))
|
w += last(gr_text_size(axis[:guide]))
|
||||||
w += last(gr_text_size(yaxis[:guide]))
|
|
||||||
end
|
end
|
||||||
return w
|
return w
|
||||||
end
|
end
|
||||||
@ -790,8 +816,90 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
h = 1mm + gr_plot_size[2] * l * px
|
h = 1mm + gr_plot_size[2] * l * px
|
||||||
toppad += h
|
toppad += h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if is3d(sp)
|
||||||
|
xaxis, yaxis, zaxis = sp[:xaxis], sp[:yaxis], sp[:zaxis]
|
||||||
|
xticks, yticks, zticks = get_ticks(sp, xaxis), get_ticks(sp, yaxis), get_ticks(sp, zaxis)
|
||||||
# Add margin for x and y ticks
|
# Add margin for x and y ticks
|
||||||
xticks, yticks = axis_drawing_info(sp)[1:2]
|
h = 0mm
|
||||||
|
if !(xticks in (nothing, false, :none))
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(xaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
||||||
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = xaxis[:rotation]
|
||||||
|
)
|
||||||
|
l = 0.01 + last(gr_get_ticks_size(xticks, xaxis[:rotation]))
|
||||||
|
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
||||||
|
end
|
||||||
|
if !(yticks in (nothing, false, :none))
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(yaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
||||||
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = yaxis[:rotation]
|
||||||
|
)
|
||||||
|
l = 0.01 + last(gr_get_ticks_size(yticks, yaxis[:rotation]))
|
||||||
|
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
||||||
|
end
|
||||||
|
if h > 0mm
|
||||||
|
if xaxis[:mirror] || yaxis[:mirror]
|
||||||
|
toppad += h
|
||||||
|
end
|
||||||
|
if !xaxis[:mirror] || !yaxis[:mirror]
|
||||||
|
bottompad += h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(zticks in (nothing, false, :none))
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(zaxis),
|
||||||
|
halign = (zaxis[:mirror] ? :left : :right),
|
||||||
|
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
||||||
|
rotation = zaxis[:rotation]
|
||||||
|
)
|
||||||
|
l = 0.01 + first(gr_get_ticks_size(zticks, zaxis[:rotation]))
|
||||||
|
w = 1mm + gr_plot_size[1] * l * px
|
||||||
|
if zaxis[:mirror]
|
||||||
|
rightpad += w
|
||||||
|
else
|
||||||
|
leftpad += w
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Add margin for x or y label
|
||||||
|
h = 0mm
|
||||||
|
if xaxis[:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:xaxis]))
|
||||||
|
l = last(gr_text_size(sp[:xaxis][:guide]))
|
||||||
|
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
||||||
|
end
|
||||||
|
if yaxis[:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:yaxis]))
|
||||||
|
l = last(gr_text_size(sp[:yaxis][:guide]))
|
||||||
|
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
||||||
|
end
|
||||||
|
if h > 0mm
|
||||||
|
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
||||||
|
toppad += h
|
||||||
|
else
|
||||||
|
bottompad += h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# Add margin for z label
|
||||||
|
if zaxis[:guide] != ""
|
||||||
|
gr_set_font(guidefont(sp[:zaxis]))
|
||||||
|
l = last(gr_text_size(sp[:zaxis][:guide]))
|
||||||
|
w = 1mm + gr_plot_size[2] * l * px
|
||||||
|
if zaxis[:guide_position] == :right || (zaxis[:guide_position] == :auto && zaxis[:mirror] == true)
|
||||||
|
rightpad += w
|
||||||
|
else
|
||||||
|
leftpad += w
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
# Add margin for x and y ticks
|
||||||
|
xticks, yticks = get_ticks(sp, sp[:xaxis]), get_ticks(sp, sp[:yaxis])
|
||||||
if !(xticks in (nothing, false, :none))
|
if !(xticks in (nothing, false, :none))
|
||||||
flip, mirror = gr_set_xticks_font(sp)
|
flip, mirror = gr_set_xticks_font(sp)
|
||||||
l = 0.01 + last(gr_get_ticks_size(xticks, sp[:xaxis][:rotation]))
|
l = 0.01 + last(gr_get_ticks_size(xticks, sp[:xaxis][:rotation]))
|
||||||
@ -812,6 +920,7 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
leftpad += w
|
leftpad += w
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Add margin for x label
|
# Add margin for x label
|
||||||
if sp[:xaxis][:guide] != ""
|
if sp[:xaxis][:guide] != ""
|
||||||
gr_set_font(guidefont(sp[:xaxis]))
|
gr_set_font(guidefont(sp[:xaxis]))
|
||||||
@ -834,6 +943,7 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
leftpad += w
|
leftpad += w
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if sp[:colorbar_title] != ""
|
if sp[:colorbar_title] != ""
|
||||||
rightpad += 4mm
|
rightpad += 4mm
|
||||||
end
|
end
|
||||||
@ -908,7 +1018,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
leg_str = string(sp[:legend])
|
leg_str = string(sp[:legend])
|
||||||
if occursin("outer", leg_str)
|
if occursin("outer", leg_str)
|
||||||
if occursin("right", leg_str)
|
if occursin("right", leg_str)
|
||||||
viewport_plotarea[2] -= legendw + 0.11
|
viewport_plotarea[2] -= legendw + 0.12
|
||||||
elseif occursin("left", leg_str)
|
elseif occursin("left", leg_str)
|
||||||
viewport_plotarea[1] += legendw + 0.11
|
viewport_plotarea[1] += legendw + 0.11
|
||||||
elseif occursin("top", leg_str)
|
elseif occursin("top", leg_str)
|
||||||
@ -920,7 +1030,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# fill in the plot area background
|
# fill in the plot area background
|
||||||
bg = plot_color(sp[:background_color_inside])
|
bg = plot_color(sp[:background_color_inside])
|
||||||
gr_fill_viewport(viewport_plotarea, bg)
|
is3d(sp) || gr_fill_viewport(viewport_plotarea, bg)
|
||||||
|
|
||||||
# reduced from before... set some flags based on the series in this subplot
|
# reduced from before... set some flags based on the series in this subplot
|
||||||
# TODO: can these be generic flags?
|
# TODO: can these be generic flags?
|
||||||
@ -995,39 +1105,228 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
GR.setlinewidth(sp.plt[:thickness_scaling])
|
GR.setlinewidth(sp.plt[:thickness_scaling])
|
||||||
|
|
||||||
if is3d(sp)
|
if is3d(sp)
|
||||||
# TODO do we really need a different clims computation here from the one
|
zmin, zmax = axis_limits(sp, :z)
|
||||||
# computed above using get_clims(sp)?
|
|
||||||
zmin, zmax = gr_lims(sp, zaxis, true)
|
|
||||||
clims3d = sp[:clims]
|
|
||||||
if is_2tuple(clims3d)
|
|
||||||
isfinite(clims3d[1]) && (zmin = clims3d[1])
|
|
||||||
isfinite(clims3d[2]) && (zmax = clims3d[2])
|
|
||||||
end
|
|
||||||
GR.setspace(zmin, zmax, round.(Int, sp[:camera])...)
|
GR.setspace(zmin, zmax, round.(Int, sp[:camera])...)
|
||||||
xtick = GR.tick(xmin, xmax) / 2
|
|
||||||
ytick = GR.tick(ymin, ymax) / 2
|
|
||||||
ztick = GR.tick(zmin, zmax) / 2
|
|
||||||
ticksize = 0.01 * (viewport_plotarea[2] - viewport_plotarea[1])
|
|
||||||
|
|
||||||
|
xticks, yticks, zticks, xaxis_segs, yaxis_segs, zaxis_segs, xtick_segs, ytick_segs, ztick_segs, xgrid_segs, ygrid_segs, zgrid_segs, xminorgrid_segs, yminorgrid_segs, zminorgrid_segs, xborder_segs, yborder_segs, zborder_segs = axis_drawing_info_3d(sp)
|
||||||
|
|
||||||
|
# fill the plot area
|
||||||
|
gr_set_fill(sp[:background_color_inside])
|
||||||
|
plot_area_x = [xmin, xmin, xmin, xmax, xmax, xmax, xmin]
|
||||||
|
plot_area_y = [ymin, ymin, ymax, ymax, ymax, ymin, ymin]
|
||||||
|
plot_area_z = [zmin, zmax, zmax, zmax, zmin, zmin, zmin]
|
||||||
|
x_bg, y_bg = unzip(GR.wc3towc.(plot_area_x, plot_area_y, plot_area_z))
|
||||||
|
GR.fillarea(x_bg, y_bg)
|
||||||
|
|
||||||
|
# draw the grid lines
|
||||||
if xaxis[:grid]
|
if xaxis[:grid]
|
||||||
gr_set_line(xaxis[:gridlinewidth], xaxis[:gridstyle], xaxis[:foreground_color_grid])
|
gr_set_line(xaxis[:gridlinewidth], xaxis[:gridstyle], xaxis[:foreground_color_grid])
|
||||||
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
||||||
GR.grid3d(xtick, 0, 0, xmin, ymax, zmin, 2, 0, 0)
|
gr_polyline3d(coords(xgrid_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:grid]
|
if yaxis[:grid]
|
||||||
gr_set_line(yaxis[:gridlinewidth], yaxis[:gridstyle], yaxis[:foreground_color_grid])
|
gr_set_line(yaxis[:gridlinewidth], yaxis[:gridstyle], yaxis[:foreground_color_grid])
|
||||||
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
||||||
GR.grid3d(0, ytick, 0, xmin, ymax, zmin, 0, 2, 0)
|
gr_polyline3d(coords(ygrid_segs)...)
|
||||||
end
|
end
|
||||||
if zaxis[:grid]
|
if zaxis[:grid]
|
||||||
gr_set_line(zaxis[:gridlinewidth], zaxis[:gridstyle], zaxis[:foreground_color_grid])
|
gr_set_line(zaxis[:gridlinewidth], zaxis[:gridstyle], zaxis[:foreground_color_grid])
|
||||||
gr_set_transparency(zaxis[:foreground_color_grid], zaxis[:gridalpha])
|
gr_set_transparency(zaxis[:foreground_color_grid], zaxis[:gridalpha])
|
||||||
GR.grid3d(0, 0, ztick, xmin, ymax, zmin, 0, 0, 2)
|
gr_polyline3d(coords(zgrid_segs)...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if xaxis[:minorgrid]
|
||||||
|
gr_set_line(xaxis[:minorgridlinewidth], xaxis[:minorgridstyle], xaxis[:foreground_color_minor_grid])
|
||||||
|
gr_set_transparency(xaxis[:foreground_color_minor_grid], xaxis[:minorgridalpha])
|
||||||
|
gr_polyline3d(coords(xminorgrid_segs)...)
|
||||||
|
end
|
||||||
|
if yaxis[:minorgrid]
|
||||||
|
gr_set_line(yaxis[:minorgridlinewidth], yaxis[:minorgridstyle], yaxis[:foreground_color_minor_grid])
|
||||||
|
gr_set_transparency(yaxis[:foreground_color_minor_grid], yaxis[:minorgridalpha])
|
||||||
|
gr_polyline3d(coords(yminorgrid_segs)...)
|
||||||
|
end
|
||||||
|
if zaxis[:minorgrid]
|
||||||
|
gr_set_line(zaxis[:minorgridlinewidth], zaxis[:minorgridstyle], zaxis[:foreground_color_minor_grid])
|
||||||
|
gr_set_transparency(zaxis[:foreground_color_minor_grid], zaxis[:minorgridalpha])
|
||||||
|
gr_polyline3d(coords(zminorgrid_segs)...)
|
||||||
|
end
|
||||||
|
gr_set_transparency(1.0)
|
||||||
|
|
||||||
|
# axis lines
|
||||||
|
if xaxis[:showaxis]
|
||||||
|
gr_set_line(1, :solid, xaxis[:foreground_color_border])
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline3d(coords(xaxis_segs)...)
|
||||||
|
end
|
||||||
|
if yaxis[:showaxis]
|
||||||
|
gr_set_line(1, :solid, yaxis[:foreground_color_border])
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline3d(coords(yaxis_segs)...)
|
||||||
|
end
|
||||||
|
if zaxis[:showaxis]
|
||||||
|
gr_set_line(1, :solid, zaxis[:foreground_color_border])
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline3d(coords(zaxis_segs)...)
|
||||||
|
end
|
||||||
|
GR.setclip(1)
|
||||||
|
|
||||||
|
# axis ticks
|
||||||
|
if xaxis[:showaxis]
|
||||||
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
|
gr_set_line(1, :solid, xaxis[:foreground_color_grid])
|
||||||
|
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:tick_direction] == :out ? xaxis[:gridalpha] : 0)
|
||||||
|
else
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
||||||
gr_set_transparency(xaxis[:foreground_color_axis])
|
end
|
||||||
GR.axes3d(xtick, 0, ztick, xmin, ymin, zmin, 2, 0, 2, -ticksize)
|
GR.setclip(0)
|
||||||
GR.axes3d(0, ytick, 0, xmax, ymin, zmin, 0, 2, 0, ticksize)
|
gr_polyline3d(coords(xtick_segs)...)
|
||||||
|
end
|
||||||
|
if yaxis[:showaxis]
|
||||||
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
|
gr_set_line(1, :solid, yaxis[:foreground_color_grid])
|
||||||
|
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:tick_direction] == :out ? yaxis[:gridalpha] : 0)
|
||||||
|
else
|
||||||
|
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
||||||
|
end
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline3d(coords(ytick_segs)...)
|
||||||
|
end
|
||||||
|
if zaxis[:showaxis]
|
||||||
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
|
gr_set_line(1, :solid, zaxis[:foreground_color_grid])
|
||||||
|
gr_set_transparency(zaxis[:foreground_color_grid], zaxis[:tick_direction] == :out ? zaxis[:gridalpha] : 0)
|
||||||
|
else
|
||||||
|
gr_set_line(1, :solid, zaxis[:foreground_color_axis])
|
||||||
|
end
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline3d(coords(ztick_segs)...)
|
||||||
|
end
|
||||||
|
GR.setclip(1)
|
||||||
|
|
||||||
|
# tick marks
|
||||||
|
if !(xticks in (:none, nothing, false)) && xaxis[:showaxis]
|
||||||
|
# x labels
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(xaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
||||||
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = xaxis[:rotation]
|
||||||
|
)
|
||||||
|
yt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(xaxis[:mirror], yaxis[:flip])
|
||||||
|
ymax
|
||||||
|
else
|
||||||
|
ymin
|
||||||
|
end
|
||||||
|
zt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(xaxis[:mirror], zaxis[:flip])
|
||||||
|
zmax
|
||||||
|
else
|
||||||
|
zmin
|
||||||
|
end
|
||||||
|
for (cv, dv) in zip(xticks...)
|
||||||
|
xi, yi = gr_w3tondc(cv, yt, zt)
|
||||||
|
if xaxis[:ticks] in (:auto, :native)
|
||||||
|
if xaxis[:formatter] in (:scientific, :auto)
|
||||||
|
# ensure correct dispatch in gr_text for automatic log ticks
|
||||||
|
if xaxis[:scale] in _logScales
|
||||||
|
dv = string(dv, "\\ ")
|
||||||
|
end
|
||||||
|
dv = convert_sci_unicode(dv)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
xi += (yaxis[:mirror] ? 1 : -1) * 1e-2 * (xaxis[:tick_direction] == :out ? 1.5 : 1.0)
|
||||||
|
yi += (xaxis[:mirror] ? 1 : -1) * 5e-3 * (xaxis[:tick_direction] == :out ? 1.5 : 1.0)
|
||||||
|
gr_text(xi, yi, string(dv))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(yticks in (:none, nothing, false)) && yaxis[:showaxis]
|
||||||
|
# y labels
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(yaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
||||||
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = yaxis[:rotation]
|
||||||
|
)
|
||||||
|
xt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(yaxis[:mirror], xaxis[:flip])
|
||||||
|
xmin
|
||||||
|
else
|
||||||
|
xmax
|
||||||
|
end
|
||||||
|
zt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(yaxis[:mirror], zaxis[:flip])
|
||||||
|
zmax
|
||||||
|
else
|
||||||
|
zmin
|
||||||
|
end
|
||||||
|
for (cv, dv) in zip(yticks...)
|
||||||
|
xi, yi = gr_w3tondc(xt, cv, zt)
|
||||||
|
if yaxis[:ticks] in (:auto, :native)
|
||||||
|
if xaxis[:formatter] in (:scientific, :auto)
|
||||||
|
# ensure correct dispatch in gr_text for automatic log ticks
|
||||||
|
if yaxis[:scale] in _logScales
|
||||||
|
dv = string(dv, "\\ ")
|
||||||
|
end
|
||||||
|
dv = convert_sci_unicode(dv)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
gr_text(xi + (yaxis[:mirror] ? -1 : 1) * 1e-2 * (yaxis[:tick_direction] == :out ? 1.5 : 1.0), yi + (yaxis[:mirror] ? 1 : -1) * 5e-3 * (yaxis[:tick_direction] == :out ? 1.5 : 1.0), string(dv))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(zticks in (:none, nothing, false)) && zaxis[:showaxis]
|
||||||
|
# z labels
|
||||||
|
gr_set_font(
|
||||||
|
tickfont(zaxis),
|
||||||
|
halign = (zaxis[:mirror] ? :left : :right),
|
||||||
|
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
||||||
|
rotation = zaxis[:rotation]
|
||||||
|
)
|
||||||
|
xt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(zaxis[:mirror], xaxis[:flip])
|
||||||
|
xmax
|
||||||
|
else
|
||||||
|
xmin
|
||||||
|
end
|
||||||
|
yt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(zaxis[:mirror], yaxis[:flip])
|
||||||
|
ymax
|
||||||
|
else
|
||||||
|
ymin
|
||||||
|
end
|
||||||
|
for (cv, dv) in zip(zticks...)
|
||||||
|
xi, yi = gr_w3tondc(xt, yt, cv)
|
||||||
|
if zaxis[:ticks] in (:auto, :native)
|
||||||
|
if zaxis[:formatter] in (:scientific, :auto)
|
||||||
|
# ensure correct dispatch in gr_text for automatic log ticks
|
||||||
|
if zaxis[:scale] in _logScales
|
||||||
|
dv = string(dv, "\\ ")
|
||||||
|
end
|
||||||
|
dv = convert_sci_unicode(dv)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
gr_text(xi + (zaxis[:mirror] ? 1 : -1) * 1e-2 * (zaxis[:tick_direction] == :out ? 1.5 : 1.0), yi, string(dv))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
#
|
||||||
|
# # border
|
||||||
|
# intensity = sp[:framestyle] == :semi ? 0.5 : 1.0
|
||||||
|
# if sp[:framestyle] in (:box, :semi)
|
||||||
|
# gr_set_line(intensity, :solid, xaxis[:foreground_color_border])
|
||||||
|
# gr_set_transparency(xaxis[:foreground_color_border], intensity)
|
||||||
|
# gr_polyline3d(coords(xborder_segs)...)
|
||||||
|
# gr_set_line(intensity, :solid, yaxis[:foreground_color_border])
|
||||||
|
# gr_set_transparency(yaxis[:foreground_color_border], intensity)
|
||||||
|
# gr_polyline3d(coords(yborder_segs)...)
|
||||||
|
# end
|
||||||
|
|
||||||
elseif ispolar(sp)
|
elseif ispolar(sp)
|
||||||
r = gr_set_viewport_polar()
|
r = gr_set_viewport_polar()
|
||||||
@ -1179,12 +1478,54 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
gr_text(xpos, viewport_subplot[4], sp[:title])
|
gr_text(xpos, viewport_subplot[4], sp[:title])
|
||||||
end
|
end
|
||||||
if is3d(sp)
|
if is3d(sp)
|
||||||
gr_set_font(guidefont(xaxis))
|
|
||||||
GR.titles3d(xaxis[:guide], yaxis[:guide], zaxis[:guide])
|
|
||||||
else
|
|
||||||
xticks, yticks = axis_drawing_info(sp)[1:2]
|
|
||||||
if xaxis[:guide] != ""
|
if xaxis[:guide] != ""
|
||||||
h = 0.01 + gr_xaxis_height(sp)
|
gr_set_font(
|
||||||
|
guidefont(xaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
||||||
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = xaxis[:rotation]
|
||||||
|
)
|
||||||
|
yg = xor(xaxis[:mirror], yaxis[:flip]) ? ymax : ymin
|
||||||
|
zg = xor(xaxis[:mirror], zaxis[:flip]) ? zmax : zmin
|
||||||
|
xg = (xmin + xmax) / 2
|
||||||
|
xndc, yndc = gr_w3tondc(xg, yg, zg)
|
||||||
|
h = gr_axis_height(sp, xaxis)
|
||||||
|
gr_text(xndc - h, yndc - h, xaxis[:guide])
|
||||||
|
end
|
||||||
|
|
||||||
|
if yaxis[:guide] != ""
|
||||||
|
gr_set_font(
|
||||||
|
guidefont(yaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
||||||
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = yaxis[:rotation]
|
||||||
|
)
|
||||||
|
xg = xor(yaxis[:mirror], xaxis[:flip]) ? xmin : xmax
|
||||||
|
yg = (ymin + ymax) / 2
|
||||||
|
zg = xor(yaxis[:mirror], zaxis[:flip]) ? zmax : zmin
|
||||||
|
xndc, yndc = gr_w3tondc(xg, yg, zg)
|
||||||
|
h = gr_axis_height(sp, yaxis)
|
||||||
|
gr_text(xndc + h, yndc - h, yaxis[:guide])
|
||||||
|
end
|
||||||
|
|
||||||
|
if zaxis[:guide] != ""
|
||||||
|
gr_set_font(
|
||||||
|
guidefont(zaxis),
|
||||||
|
halign = (:left, :hcenter, :right)[sign(zaxis[:rotation]) + 2],
|
||||||
|
valign = (zaxis[:mirror] ? :bottom : :top),
|
||||||
|
rotation = zaxis[:rotation]
|
||||||
|
)
|
||||||
|
xg = xor(zaxis[:mirror], xaxis[:flip]) ? xmax : xmin
|
||||||
|
yg = xor(zaxis[:mirror], yaxis[:flip]) ? ymax : ymin
|
||||||
|
zg = (zmin + zmax) / 2
|
||||||
|
xndc, yndc = gr_w3tondc(xg, yg, zg)
|
||||||
|
w = gr_axis_width(sp, zaxis)
|
||||||
|
GR.setcharup(-1, 0)
|
||||||
|
gr_text(xndc - w, yndc, zaxis[:guide])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if xaxis[:guide] != ""
|
||||||
|
h = 0.01 + gr_axis_height(sp, xaxis)
|
||||||
gr_set_font(guidefont(xaxis))
|
gr_set_font(guidefont(xaxis))
|
||||||
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
@ -1196,7 +1537,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if yaxis[:guide] != ""
|
if yaxis[:guide] != ""
|
||||||
w = 0.02 + gr_yaxis_width(sp)
|
w = 0.02 + gr_axis_width(sp, yaxis)
|
||||||
gr_set_font(guidefont(yaxis))
|
gr_set_font(guidefont(yaxis))
|
||||||
GR.setcharup(-1, 0)
|
GR.setcharup(-1, 0)
|
||||||
if yaxis[:guide_position] == :right || (yaxis[:guide_position] == :auto && yaxis[:mirror] == true)
|
if yaxis[:guide_position] == :right || (yaxis[:guide_position] == :auto && yaxis[:mirror] == true)
|
||||||
@ -1575,7 +1916,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
for ann in sp[:annotations]
|
for ann in sp[:annotations]
|
||||||
x, y, val = locate_annotation(sp, ann...)
|
x, y, val = locate_annotation(sp, ann...)
|
||||||
x, y = if is3d(sp)
|
x, y = if is3d(sp)
|
||||||
# GR.wc3towc(x, y, z)
|
gr_w3tondc(x, y, z)
|
||||||
else
|
else
|
||||||
GR.wctondc(x, y)
|
GR.wctondc(x, y)
|
||||||
end
|
end
|
||||||
|
|||||||
1724
src/precompile.jl
1724
src/precompile.jl
File diff suppressed because it is too large
Load Diff
@ -145,16 +145,18 @@ end
|
|||||||
|
|
||||||
Segments() = Segments(Float64)
|
Segments() = Segments(Float64)
|
||||||
Segments(::Type{T}) where {T} = Segments(T[])
|
Segments(::Type{T}) where {T} = Segments(T[])
|
||||||
Segments(p::Int) = Segments(NTuple{2,Float64}[])
|
Segments(p::Int) = Segments(NTuple{p, Float64}[])
|
||||||
|
|
||||||
|
|
||||||
# Segments() = Segments(zeros(0))
|
# Segments() = Segments(zeros(0))
|
||||||
|
|
||||||
to_nan(::Type{Float64}) = NaN
|
to_nan(::Type{Float64}) = NaN
|
||||||
to_nan(::Type{NTuple{2,Float64}}) = (NaN, NaN)
|
to_nan(::Type{NTuple{2,Float64}}) = (NaN, NaN)
|
||||||
|
to_nan(::Type{NTuple{3,Float64}}) = (NaN, NaN, NaN)
|
||||||
|
|
||||||
coords(segs::Segments{Float64}) = segs.pts
|
coords(segs::Segments{Float64}) = segs.pts
|
||||||
coords(segs::Segments{NTuple{2,Float64}}) = Float64[p[1] for p in segs.pts], Float64[p[2] for p in segs.pts]
|
coords(segs::Segments{NTuple{2,Float64}}) = Float64[p[1] for p in segs.pts], Float64[p[2] for p in segs.pts]
|
||||||
|
coords(segs::Segments{NTuple{3,Float64}}) = Float64[p[1] for p in segs.pts], Float64[p[2] for p in segs.pts], Float64[p[3] for p in segs.pts]
|
||||||
|
|
||||||
function Base.push!(segments::Segments{T}, vs...) where T
|
function Base.push!(segments::Segments{T}, vs...) where T
|
||||||
if !isempty(segments.pts)
|
if !isempty(segments.pts)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user