implement 3d tick labels
This commit is contained in:
parent
c7cc76b2b6
commit
06afcedf56
@ -291,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()
|
||||||
@ -1029,14 +1017,7 @@ 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])...)
|
||||||
|
|
||||||
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)
|
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)
|
||||||
@ -1128,62 +1109,121 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# TODO: tick labels
|
# TODO: tick labels
|
||||||
|
|
||||||
# # tick marks
|
# tick marks
|
||||||
# if !(xticks in (:none, nothing, false)) && xaxis[:showaxis]
|
if !(xticks in (:none, nothing, false)) && xaxis[:showaxis]
|
||||||
# # x labels
|
# x labels
|
||||||
# flip, mirror = gr_set_xticks_font(sp)
|
gr_set_font(
|
||||||
# for (cv, dv) in zip(xticks...)
|
tickfont(xaxis),
|
||||||
# # use xor ($) to get the right y coords
|
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
||||||
# xi, yi = GR.wctondc(cv, sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? ymax : ymin)
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
# if xaxis[:ticks] in (:auto, :native)
|
rotation = xaxis[:rotation]
|
||||||
# # ensure correct dispatch in gr_text for automatic log ticks
|
)
|
||||||
# if xaxis[:scale] in _logScales
|
yt = if sp[:framestyle] == :origin
|
||||||
# dv = string(dv, "\\ ")
|
0
|
||||||
# elseif xaxis[:formatter] in (:scientific, :auto)
|
elseif xor(xaxis[:mirror], yaxis[:flip])
|
||||||
# dv = convert_sci_unicode(dv)
|
ymax
|
||||||
# end
|
else
|
||||||
# end
|
ymin
|
||||||
# gr_text(xi, yi + (mirror ? 1 : -1) * 5e-3 * (xaxis[:tick_direction] == :out ? 1.5 : 1.0), string(dv))
|
end
|
||||||
# end
|
zt = if sp[:framestyle] == :origin
|
||||||
# end
|
0
|
||||||
#
|
elseif xor(xaxis[:mirror], zaxis[:flip])
|
||||||
# if !(yticks in (:none, nothing, false)) && yaxis[:showaxis]
|
zmax
|
||||||
# # y labels
|
else
|
||||||
# flip, mirror = gr_set_yticks_font(sp)
|
zmin
|
||||||
# for (cv, dv) in zip(yticks...)
|
end
|
||||||
# # use xor ($) to get the right y coords
|
for (cv, dv) in zip(xticks...)
|
||||||
# xi, yi = GR.wctondc(sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? xmax : xmin, cv)
|
xi, yi, zi = GR.wc3towc(cv, yt, zt)
|
||||||
# # @show cv dv xmin xi yi
|
xi, yi = GR.wctondc(xi, yi)
|
||||||
# if yaxis[:ticks] in (:auto, :native)
|
@show xi, yi
|
||||||
# # ensure correct dispatch in gr_text for automatic log ticks
|
if xaxis[:ticks] in (:auto, :native)
|
||||||
# if yaxis[:scale] in _logScales
|
# ensure correct dispatch in gr_text for automatic log ticks
|
||||||
# dv = string(dv, "\\ ")
|
if xaxis[:scale] in _logScales
|
||||||
# elseif yaxis[:formatter] in (:scientific, :auto)
|
dv = string(dv, "\\ ")
|
||||||
# dv = convert_sci_unicode(dv)
|
elseif xaxis[:formatter] in (:scientific, :auto)
|
||||||
# end
|
dv = convert_sci_unicode(dv)
|
||||||
# end
|
end
|
||||||
# gr_text(xi + (mirror ? 1 : -1) * 1e-2 * (yaxis[:tick_direction] == :out ? 1.5 : 1.0), yi, string(dv))
|
end
|
||||||
# end
|
xi += (yaxis[:mirror] ? 1 : -1) * 1e-2 * (xaxis[:tick_direction] == :out ? 1.5 : 1.0)
|
||||||
# end
|
yi += (xaxis[:mirror] ? 1 : -1) * 5e-3 * (xaxis[:tick_direction] == :out ? 1.5 : 1.0)
|
||||||
#
|
@show xi, yi
|
||||||
# if !(zticks in (:none, nothing, false)) && zaxis[:showaxis]
|
gr_text(xi, yi, string(dv))
|
||||||
# # y labels
|
end
|
||||||
# flip, mirror = gr_set_yticks_font(sp) # TODO for z
|
end
|
||||||
# for (cv, dv) in zip(zticks...)
|
|
||||||
# # use xor ($) to get the right y coords
|
if !(yticks in (:none, nothing, false)) && yaxis[:showaxis]
|
||||||
# xi, yi = GR.wctondc(sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? xmax : xmin, cv)
|
# y labels
|
||||||
# # @show cv dv xmin xi yi
|
gr_set_font(
|
||||||
# if yaxis[:ticks] in (:auto, :native)
|
tickfont(yaxis),
|
||||||
# # ensure correct dispatch in gr_text for automatic log ticks
|
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
||||||
# if yaxis[:scale] in _logScales
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
# dv = string(dv, "\\ ")
|
rotation = yaxis[:rotation]
|
||||||
# elseif yaxis[:formatter] in (:scientific, :auto)
|
)
|
||||||
# dv = convert_sci_unicode(dv)
|
xt = if sp[:framestyle] == :origin
|
||||||
# end
|
0
|
||||||
# end
|
elseif xor(yaxis[:mirror], xaxis[:flip])
|
||||||
# gr_text(xi + (mirror ? 1 : -1) * 1e-2 * (yaxis[:tick_direction] == :out ? 1.5 : 1.0), yi, string(dv))
|
xmin
|
||||||
# end
|
else
|
||||||
# end
|
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, zi = GR.wc3towc(xt, cv, zt)
|
||||||
|
xi, yi = GR.wctondc(xi, yi)
|
||||||
|
if yaxis[:ticks] in (:auto, :native)
|
||||||
|
# ensure correct dispatch in gr_text for automatic log ticks
|
||||||
|
if yaxis[:scale] in _logScales
|
||||||
|
dv = string(dv, "\\ ")
|
||||||
|
elseif xaxis[:formatter] in (:scientific, :auto)
|
||||||
|
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] ? :right : :left),
|
||||||
|
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
||||||
|
rotation = zaxis[:rotation]
|
||||||
|
)
|
||||||
|
xt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(zaxis[:mirror], xaxis[:flip])
|
||||||
|
xmin
|
||||||
|
else
|
||||||
|
xmax
|
||||||
|
end
|
||||||
|
yt = if sp[:framestyle] == :origin
|
||||||
|
0
|
||||||
|
elseif xor(zaxis[:mirror], yaxis[:flip])
|
||||||
|
ymin
|
||||||
|
else
|
||||||
|
ymax
|
||||||
|
end
|
||||||
|
for (cv, dv) in zip(zticks...)
|
||||||
|
xi, yi, zi = GR.wc3towc(xt, yt, cv)
|
||||||
|
xi, yi = GR.wctondc(xi, yi)
|
||||||
|
if zaxis[:ticks] in (:auto, :native)
|
||||||
|
# ensure correct dispatch in gr_text for automatic log ticks
|
||||||
|
if zaxis[:scale] in _logScales
|
||||||
|
dv = string(dv, "\\ ")
|
||||||
|
elseif zaxis[:formatter] in (:scientific, :auto)
|
||||||
|
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
|
# # border
|
||||||
# intensity = sp[:framestyle] == :semi ? 0.5 : 1.0
|
# intensity = sp[:framestyle] == :semi ? 0.5 : 1.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user