Skip to content

Commit

Permalink
add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Dec 23, 2023
1 parent 13eb2eb commit 55b99f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 8 additions & 1 deletion ReferenceTests/src/tests/examples2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,7 @@ function ppu_test_plot(resolution, px_per_unit, scalefactor)
fig, ax, pl = scatter(1:4, markersize=100, color=1:4, figure=(; size=resolution), axis=(; titlesize=50, title="ppu: $px_per_unit, sf: $scalefactor"))
DataInspector(ax)
hidedecorations!(ax)
return fig
fig
end

@reference_test "px_per_unit and scalefactor" begin
Expand All @@ -1373,3 +1373,10 @@ end
st
end
end

@reference_test "spurious minor tick (#3487)" begin
fig = Figure(size=(227, 170))
ax = Axis(fig[1, 1]; yticks = 0:.2:1, yminorticksvisible = true)
ylims!(ax, 0, 1)
fig
end
6 changes: 3 additions & 3 deletions src/makielayout/lineaxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ end

# if labels are given manually, it's possible that some of them are outside the displayed limits
# we only check approximately because otherwise because of floating point errors, ticks can be dismissed sometimes
is_valid_tick(tv, limits) = (limits[1] <= tv || limits[1] tv) && (tv <= limits[2] || tv limits[2])
is_within_limits(tv, limits) = (limits[1] tv || limits[1] tv) && (tv limits[2] || tv limits[2])

function update_tickpos_string(closure_args, tickvalues_labels_unfiltered, reversed::Bool, scale)

Expand All @@ -208,7 +208,7 @@ function update_tickpos_string(closure_args, tickvalues_labels_unfiltered, rever
lim_o = limits[1]
lim_w = limits[2] - limits[1]

i_values_within_limits = findall(tv -> is_valid_tick(tv, limits), tickvalues_unfiltered)
i_values_within_limits = findall(tv -> is_within_limits(tv, limits), tickvalues_unfiltered)

tickvalues[] = tickvalues_unfiltered[i_values_within_limits]

Expand Down Expand Up @@ -238,7 +238,7 @@ function update_minor_ticks(minortickpositions, limits::NTuple{2, Float32}, pos_
px_o = extents[1]
px_width = extents[2] - extents[1]

minortickvalues = filter(tv -> is_valid_tick(tv, limits), minortickvalues_unfiltered)
minortickvalues = filter(tv -> is_within_limits(tv, limits), minortickvalues_unfiltered)

tickvalues_scaled = scale.(minortickvalues)

Expand Down

0 comments on commit 55b99f3

Please sign in to comment.