implement tick_direction for GR, PyPlot, Plotly and GLVisualize
This commit is contained in:
parent
9eac6a1db0
commit
b73ea55bbd
@ -115,4 +115,5 @@ const _arg_desc = KW(
|
|||||||
:gridalpha => "Number in [0,1]. The alpha/opacity override for the grid lines.",
|
:gridalpha => "Number in [0,1]. The alpha/opacity override for the grid lines.",
|
||||||
:gridstyle => "Symbol. Style of the grid lines. Choose from $(_allStyles)",
|
:gridstyle => "Symbol. Style of the grid lines. Choose from $(_allStyles)",
|
||||||
:gridlinewidth => "Number. Width of the grid lines (in pixels)",
|
:gridlinewidth => "Number. Width of the grid lines (in pixels)",
|
||||||
|
:tick_direction => "Symbol. Direction of the ticks. `:in` or `:out`"
|
||||||
)
|
)
|
||||||
|
|||||||
@ -322,6 +322,7 @@ const _axis_defaults = KW(
|
|||||||
:gridalpha => 0.1,
|
:gridalpha => 0.1,
|
||||||
:gridstyle => :solid,
|
:gridstyle => :solid,
|
||||||
:gridlinewidth => 0.5,
|
:gridlinewidth => 0.5,
|
||||||
|
:tick_direction => :in,
|
||||||
)
|
)
|
||||||
|
|
||||||
const _suppress_warnings = Set{Symbol}([
|
const _suppress_warnings = Set{Symbol}([
|
||||||
@ -511,7 +512,7 @@ add_aliases(:stride, :wirefame_stride, :surface_stride, :surf_str, :str)
|
|||||||
add_aliases(:gridlinewidth, :gridwidth, :grid_linewidth, :grid_width, :gridlw, :grid_lw)
|
add_aliases(:gridlinewidth, :gridwidth, :grid_linewidth, :grid_width, :gridlw, :grid_lw)
|
||||||
add_aliases(:gridstyle, :grid_style, :gridlinestyle, :grid_linestyle, :grid_ls, :gridls)
|
add_aliases(:gridstyle, :grid_style, :gridlinestyle, :grid_linestyle, :grid_ls, :gridls)
|
||||||
add_aliases(:framestyle, :frame_style, :frame, :axesstyle, :axes_style, :boxstyle, :box_style, :box, :borderstyle, :border_style, :border)
|
add_aliases(:framestyle, :frame_style, :frame, :axesstyle, :axes_style, :boxstyle, :box_style, :box, :borderstyle, :border_style, :border)
|
||||||
|
add_aliases(:tick_direction, :tickdirection, :tick_dir, :tickdir, :tick_orientation, :tickorientation, :tick_or, :tickor)
|
||||||
|
|
||||||
# add all pluralized forms to the _keyAliases dict
|
# add all pluralized forms to the _keyAliases dict
|
||||||
for arg in keys(_series_defaults)
|
for arg in keys(_series_defaults)
|
||||||
|
|||||||
18
src/axes.jl
18
src/axes.jl
@ -530,13 +530,14 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
if !(xaxis[:ticks] in (nothing, false))
|
if !(xaxis[:ticks] in (nothing, false))
|
||||||
f = scalefunc(yaxis[:scale])
|
f = scalefunc(yaxis[:scale])
|
||||||
invf = invscalefunc(yaxis[:scale])
|
invf = invscalefunc(yaxis[:scale])
|
||||||
t1 = invf(f(ymin) + 0.015*(f(ymax)-f(ymin)))
|
ticks_in = xaxis[:tick_direction] == :out ? -1 : 1
|
||||||
t2 = invf(f(ymax) - 0.015*(f(ymax)-f(ymin)))
|
t1 = invf(f(ymin) + 0.013 * (f(ymax) - f(ymin)) * ticks_in)
|
||||||
t3 = invf(f(0) - 0.015*(f(ymax)-f(ymin)))
|
t2 = invf(f(ymax) - 0.013 * (f(ymax) - f(ymin)) * ticks_in)
|
||||||
|
t3 = invf(f(0) + 0.013 * (f(ymax) - f(ymin)) * ticks_in)
|
||||||
|
|
||||||
for xtick in xticks[1]
|
for xtick in xticks[1]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
(0, xaxis[:mirror] ? -t3 : t3)
|
(0, t3)
|
||||||
else
|
else
|
||||||
xaxis[:mirror] ? (ymax, t2) : (ymin, t1)
|
xaxis[:mirror] ? (ymax, t2) : (ymin, t1)
|
||||||
end
|
end
|
||||||
@ -560,13 +561,14 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
if !(yaxis[:ticks] in (nothing, false))
|
if !(yaxis[:ticks] in (nothing, false))
|
||||||
f = scalefunc(xaxis[:scale])
|
f = scalefunc(xaxis[:scale])
|
||||||
invf = invscalefunc(xaxis[:scale])
|
invf = invscalefunc(xaxis[:scale])
|
||||||
t1 = invf(f(xmin) + 0.015*(f(xmax)-f(xmin)))
|
ticks_in = yaxis[:tick_direction] == :out ? -1 : 1
|
||||||
t2 = invf(f(xmax) - 0.015*(f(xmax)-f(xmin)))
|
t1 = invf(f(xmin) + 0.013 * (f(xmax) - f(xmin)) * ticks_in)
|
||||||
t3 = invf(f(0) - 0.015*(f(xmax)-f(xmin)))
|
t2 = invf(f(xmax) - 0.013 * (f(xmax) - f(xmin)) * ticks_in)
|
||||||
|
t3 = invf(f(0) + 0.013 * (f(xmax) - f(xmin)) * ticks_in)
|
||||||
|
|
||||||
for ytick in yticks[1]
|
for ytick in yticks[1]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
(0, yaxis[:mirror] ? -t3 : t3)
|
(0, t3)
|
||||||
else
|
else
|
||||||
yaxis[:mirror] ? (xmax, t2) : (xmin, t1)
|
yaxis[:mirror] ? (xmax, t2) : (xmin, t1)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -827,7 +827,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# use xor ($) to get the right y coords
|
# use xor ($) to get the right y coords
|
||||||
xi, yi = GR.wctondc(cv, sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? ymax : ymin)
|
xi, yi = GR.wctondc(cv, sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? ymax : ymin)
|
||||||
# @show cv dv ymin xi yi flip mirror (flip $ mirror)
|
# @show cv dv ymin xi yi flip mirror (flip $ mirror)
|
||||||
gr_text(xi, yi + (mirror ? 1 : -1) * 5e-3, string(dv))
|
gr_text(xi, yi + (mirror ? 1 : -1) * 5e-3 * (xaxis[:tick_direction] == :out ? 1.5 : 1.0), string(dv))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -838,7 +838,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# use xor ($) to get the right y coords
|
# use xor ($) to get the right y coords
|
||||||
xi, yi = GR.wctondc(sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? xmax : xmin, cv)
|
xi, yi = GR.wctondc(sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? xmax : xmin, cv)
|
||||||
# @show cv dv xmin xi yi
|
# @show cv dv xmin xi yi
|
||||||
gr_text(xi + (mirror ? 1 : -1) * 1e-2, yi, string(dv))
|
gr_text(xi + (mirror ? 1 : -1) * 1e-2 * (yaxis[:tick_direction] == :out ? 1.5 : 1.0), yi, string(dv))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -235,7 +235,7 @@ function plotly_axis(axis::Axis, sp::Subplot)
|
|||||||
:zerolinecolor => rgba_string(axis[:foreground_color_axis]),
|
:zerolinecolor => rgba_string(axis[:foreground_color_axis]),
|
||||||
:showline => framestyle in (:box, :axes),
|
:showline => framestyle in (:box, :axes),
|
||||||
:linecolor => rgba_string(plot_color(axis[:foreground_color_axis])),
|
:linecolor => rgba_string(plot_color(axis[:foreground_color_axis])),
|
||||||
:ticks => "inside",
|
:ticks => axis[:tick_direction] == :out ? "outside" : "inside",
|
||||||
:mirror => framestyle == :box,
|
:mirror => framestyle == :box,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1052,6 +1052,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
ticks[2][ticks[1] .== 0] = ""
|
ticks[2][ticks[1] .== 0] = ""
|
||||||
end
|
end
|
||||||
py_set_ticks(ax, ticks, letter)
|
py_set_ticks(ax, ticks, letter)
|
||||||
|
pyaxis[:set_tick_params](direction = axis[:tick_direction] == :out ? "out" : "in")
|
||||||
ax[Symbol("set_", letter, "label")](axis[:guide])
|
ax[Symbol("set_", letter, "label")](axis[:guide])
|
||||||
if get(axis.d, :flip, false)
|
if get(axis.d, :flip, false)
|
||||||
ax[Symbol("invert_", letter, "axis")]()
|
ax[Symbol("invert_", letter, "axis")]()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user