Skip to content

Commit

Permalink
fix minor ticks (#2027)
Browse files Browse the repository at this point in the history
* fix minor ticks

* thicker grid/tick
  • Loading branch information
SimonDanisch committed Jun 6, 2022
1 parent 863a46f commit 33751ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
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

0 comments on commit 33751ef

Please sign in to comment.