Merge pull request #3458 from daschw/tickmarks
add `tick_direction=:none` option to hide tick marks
This commit is contained in:
commit
57ba6aa5a9
@ -165,7 +165,7 @@ const _arg_desc = KW(
|
|||||||
:minorgridalpha => "Number in [0,1]. The alpha/opacity override for the minorgrid lines.",
|
:minorgridalpha => "Number in [0,1]. The alpha/opacity override for the minorgrid lines.",
|
||||||
:minorgridstyle => "Symbol. Style of the minor grid lines. Choose from $(_allStyles)",
|
:minorgridstyle => "Symbol. Style of the minor grid lines. Choose from $(_allStyles)",
|
||||||
:minorgridlinewidth => "Number. Width of the minor grid lines (in pixels)",
|
:minorgridlinewidth => "Number. Width of the minor grid lines (in pixels)",
|
||||||
:tick_direction => "Symbol. Direction of the ticks. `:in` or `:out`",
|
:tick_direction => "Symbol. Direction of the ticks. `:in`, `:out` or `:none`",
|
||||||
:showaxis => "Bool, Symbol or String. Show the axis. `true`, `false`, `:show`, `:hide`, `:yes`, `:no`, `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:off`",
|
:showaxis => "Bool, Symbol or String. Show the axis. `true`, `false`, `:show`, `:hide`, `:yes`, `:no`, `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:off`",
|
||||||
:widen => "Bool. Widen the axis limits by a small factor to avoid cut-off markers and lines at the borders. Defaults to `true`.",
|
:widen => "Bool. Widen the axis limits by a small factor to avoid cut-off markers and lines at the borders. Defaults to `true`.",
|
||||||
:draw_arrow => "Bool. Draw arrow at the end of the axis.",
|
:draw_arrow => "Bool. Draw arrow at the end of the axis.",
|
||||||
|
|||||||
38
src/axes.jl
38
src/axes.jl
@ -697,17 +697,19 @@ function axis_drawing_info(sp, letter)
|
|||||||
if !(ax[:ticks] in (:none, nothing, false))
|
if !(ax[:ticks] in (:none, nothing, false))
|
||||||
f = RecipesPipeline.scale_func(oax[:scale])
|
f = RecipesPipeline.scale_func(oax[:scale])
|
||||||
invf = RecipesPipeline.inverse_scale_func(oax[:scale])
|
invf = RecipesPipeline.inverse_scale_func(oax[:scale])
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
if ax[:tick_direction] !== :none
|
||||||
t = invf(f(0) + 0.012 * (f(oamax) - f(oamin)))
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
(-t, t)
|
t = invf(f(0) + 0.012 * (f(oamax) - f(oamin)))
|
||||||
else
|
(-t, t)
|
||||||
ticks_in = ax[:tick_direction] == :out ? -1 : 1
|
else
|
||||||
t = invf(f(oa1) + 0.012 * (f(oa2) - f(oa1)) * ticks_in)
|
ticks_in = ax[:tick_direction] == :out ? -1 : 1
|
||||||
(oa1, t)
|
t = invf(f(oa1) + 0.012 * (f(oa2) - f(oa1)) * ticks_in)
|
||||||
|
(oa1, t)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for tick in ticks[1]
|
for tick in ticks[1]
|
||||||
if ax[:showaxis]
|
if ax[:showaxis] && ax[:tick_direction] !== :none
|
||||||
push!(
|
push!(
|
||||||
tick_segments,
|
tick_segments,
|
||||||
reverse_if((tick, tick_start), isy),
|
reverse_if((tick, tick_start), isy),
|
||||||
@ -834,18 +836,20 @@ function axis_drawing_info_3d(sp, letter)
|
|||||||
if !(ax[:ticks] in (:none, nothing, false))
|
if !(ax[:ticks] in (:none, nothing, false))
|
||||||
f = RecipesPipeline.scale_func(nax[:scale])
|
f = RecipesPipeline.scale_func(nax[:scale])
|
||||||
invf = RecipesPipeline.inverse_scale_func(nax[:scale])
|
invf = RecipesPipeline.inverse_scale_func(nax[:scale])
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
if ax[:tick_direction] !== :none
|
||||||
t = invf(f(0) + 0.012 * (f(namax) - f(namin)))
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
(-t, t)
|
t = invf(f(0) + 0.012 * (f(namax) - f(namin)))
|
||||||
else
|
(-t, t)
|
||||||
ticks_in = ax[:tick_direction] == :out ? -1 : 1
|
else
|
||||||
t = invf(f(na0) + 0.012 * (f(na1) - f(na0)) * ticks_in)
|
ticks_in = ax[:tick_direction] == :out ? -1 : 1
|
||||||
(na0, t)
|
t = invf(f(na0) + 0.012 * (f(na1) - f(na0)) * ticks_in)
|
||||||
|
(na0, t)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ga0, ga1 = sp[:framestyle] in (:origin, :zerolines) ? (namin, namax) : (na0, na1)
|
ga0, ga1 = sp[:framestyle] in (:origin, :zerolines) ? (namin, namax) : (na0, na1)
|
||||||
for tick in ticks[1]
|
for tick in ticks[1]
|
||||||
if ax[:showaxis]
|
if ax[:showaxis] && ax[:tick_direction] !== :none
|
||||||
push!(
|
push!(
|
||||||
tick_segments,
|
tick_segments,
|
||||||
sort_3d_axes(tick, tick_start, fa0, letter),
|
sort_3d_axes(tick, tick_start, fa0, letter),
|
||||||
@ -875,7 +879,7 @@ function axis_drawing_info_3d(sp, letter)
|
|||||||
(na0, t)
|
(na0, t)
|
||||||
end
|
end
|
||||||
for tick in minor_ticks
|
for tick in minor_ticks
|
||||||
if ax[:showaxis]
|
if ax[:showaxis] && ax[:tick_direction] !== :none
|
||||||
push!(
|
push!(
|
||||||
tick_segments,
|
tick_segments,
|
||||||
sort_3d_axes(tick, tick_start, fa0, letter),
|
sort_3d_axes(tick, tick_start, fa0, letter),
|
||||||
|
|||||||
@ -1278,11 +1278,18 @@ function pgfx_axis!(opt::PGFPlotsX.Options, sp::Subplot, letter)
|
|||||||
else
|
else
|
||||||
push!(opt, string(letter, "ticklabels") => "{}")
|
push!(opt, string(letter, "ticklabels") => "{}")
|
||||||
end
|
end
|
||||||
push!(
|
if axis[:tick_direction] === :none
|
||||||
opt,
|
push!(
|
||||||
string(letter, "tick align") =>
|
opt,
|
||||||
(axis[:tick_direction] == :out ? "outside" : "inside"),
|
string(letter, "tick style") => "draw=none",
|
||||||
)
|
)
|
||||||
|
else
|
||||||
|
push!(
|
||||||
|
opt,
|
||||||
|
string(letter, "tick align") =>
|
||||||
|
(axis[:tick_direction] == :out ? "outside" : "inside"),
|
||||||
|
)
|
||||||
|
end
|
||||||
push!(
|
push!(
|
||||||
opt, string(letter, "ticklabel style") => pgfx_get_ticklabel_style(sp, axis)
|
opt, string(letter, "ticklabel style") => pgfx_get_ticklabel_style(sp, axis)
|
||||||
)
|
)
|
||||||
|
|||||||
@ -143,7 +143,8 @@ function plotly_axis(axis, sp, anchor = nothing, domain = nothing)
|
|||||||
:zerolinecolor => rgba_string(axis[:foreground_color_axis]),
|
:zerolinecolor => rgba_string(axis[:foreground_color_axis]),
|
||||||
:showline => framestyle in (:box, :axes) && axis[:showaxis],
|
:showline => framestyle in (:box, :axes) && axis[:showaxis],
|
||||||
:linecolor => rgba_string(plot_color(axis[:foreground_color_axis])),
|
:linecolor => rgba_string(plot_color(axis[:foreground_color_axis])),
|
||||||
:ticks => axis[:tick_direction] == :out ? "outside" : "inside",
|
:ticks => axis[:tick_direction] === :out ? "outside" :
|
||||||
|
axis[:tick_direction] === :in ? "inside" : "",
|
||||||
:mirror => framestyle == :box,
|
:mirror => framestyle == :box,
|
||||||
:showticklabels => axis[:showaxis],
|
:showticklabels => axis[:showaxis],
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1022,7 +1022,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
cbar_axis."set_tick_params"(
|
cbar_axis."set_tick_params"(
|
||||||
direction = axis[:tick_direction] == :out ? "out" : "in",
|
direction = axis[:tick_direction] == :out ? "out" : "in",
|
||||||
width=py_thickness_scale(plt, intensity),
|
width=py_thickness_scale(plt, intensity),
|
||||||
length= 5 * py_thickness_scale(plt, intensity)
|
length = axis[:tick_direction] == :none ? 0 : 5 * py_thickness_scale(plt, intensity)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -1137,7 +1137,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
pyaxis."set_tick_params"(
|
pyaxis."set_tick_params"(
|
||||||
direction = axis[:tick_direction] == :out ? "out" : "in",
|
direction = axis[:tick_direction] == :out ? "out" : "in",
|
||||||
width=py_thickness_scale(plt, intensity),
|
width=py_thickness_scale(plt, intensity),
|
||||||
length= 5 * py_thickness_scale(plt, intensity)
|
length = axis[:tick_direction] == :none ? 0 : 5 * py_thickness_scale(plt, intensity)
|
||||||
)
|
)
|
||||||
|
|
||||||
getproperty(ax, Symbol("set_", letter, "label"))(axis[:guide])
|
getproperty(ax, Symbol("set_", letter, "label"))(axis[:guide])
|
||||||
@ -1176,7 +1176,8 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
pyaxis."set_tick_params"(
|
pyaxis."set_tick_params"(
|
||||||
which = "minor",
|
which = "minor",
|
||||||
direction = axis[:tick_direction] == :out ? "out" : "in",
|
direction = axis[:tick_direction] == :out ? "out" : "in",
|
||||||
width=py_thickness_scale(plt, intensity))
|
length = axis[:tick_direction] == :none ? 0 : py_thickness_scale(plt, intensity),
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
if axis[:minorgrid]
|
if axis[:minorgrid]
|
||||||
@ -1186,7 +1187,8 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
pyaxis."set_tick_params"(
|
pyaxis."set_tick_params"(
|
||||||
which = "minor",
|
which = "minor",
|
||||||
direction = axis[:tick_direction] == :out ? "out" : "in",
|
direction = axis[:tick_direction] == :out ? "out" : "in",
|
||||||
width=py_thickness_scale(plt, intensity))
|
length = axis[:tick_direction] == :none ? 0 : py_thickness_scale(plt, intensity)
|
||||||
|
)
|
||||||
|
|
||||||
pyaxis."grid"(true,
|
pyaxis."grid"(true,
|
||||||
which = "minor",
|
which = "minor",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user