Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix minor ticks #2027

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,20 @@ end
# use thick strokewidth, so it will make tests fail if something is missing
poly([Rect2f(0, 0, 1, 1)], color=:green, strokewidth=100, strokecolor=:black)
end

@reference_test "minor grid & scales" begin
data = LinRange(0.01, 0.99, 200)
f = Figure(resolution = (800, 800))
for (i, scale) in enumerate([log10, log2, log, sqrt, Makie.logit, identity])
row, col = fldmod1(i, 2)
Axis(f[row, col], yscale = scale, title = string(scale),
yminorticksvisible = true, yminorgridvisible = true,
xminorticksvisible = true, xminorgridvisible = true,
yminortickwidth = 4.0, xminortickwidth = 4.0,
yminorgridwidth = 6.0, xminorgridwidth = 6.0,
yminorticks = IntervalsBetween(3))

lines!(data, color = :blue)
end
f
end
10 changes: 4 additions & 6 deletions src/makielayout/lineaxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@ function update_tickpos_string(closure_args, tickvalues_labels_unfiltered, rever
return
end

function update_minor_ticks(minortickpositions, limits_obs, pos_extents_horizontal, minortickvalues, scale, reversed::Bool)
function update_minor_ticks(minortickpositions, limits::Tuple{Float32, Float32}, pos_extents_horizontal, minortickvalues, scale, reversed::Bool)

limits = limits_obs[]::Tuple{Float32, Float32}

position::Float32, extents_uncorrected::NTuple{2, Float32}, horizontal::Bool = pos_extents_horizontal[]
position::Float32, extents_uncorrected::NTuple{2, Float32}, horizontal::Bool = pos_extents_horizontal

extents = reversed ? reverse(extents_uncorrected) : extents_uncorrected

Expand Down Expand Up @@ -397,8 +395,8 @@ function LineAxis(parent::Scene, attrs::Attributes)
return
end

on(minortickvalues) do mtv
update_minor_ticks(minortickpositions, limits, pos_extents_horizontal, mtv, attrs.scale[], reversed[])
onany(minortickvalues, limits, pos_extents_horizontal) do mtv, limits, peh
update_minor_ticks(minortickpositions, limits, peh, mtv, attrs.scale[], reversed[])
end

onany(update_tick_obs,
Expand Down