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: reintroduce vmin, vmax into get_ticks; addresses #4441 #4442

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/makielayout/lineaxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,7 @@

Convert tickvalues to a float array by default.
"""
get_tickvalues(tickvalues, vmin, vmax) = convert(Vector{Float64}, tickvalues)

get_tickvalues(tickvalues, vmin, vmax) = filter!(p -> vmin ≤ p ≤ vmax, convert(Vector{Float64}, tickvalues))

# function get_tickvalues(l::LogitTicks, vmin, vmax)
# ticks_scaled = get_tickvalues(l.linear_ticks, identity, logit_10(vmin), logit_10(vmax))
Expand Down Expand Up @@ -711,7 +710,11 @@
# Replaces hyphens in negative numbers with the unicode MINUS_SIGN
function showoff_minus(x::AbstractVector)
# TODO: don't use the `replace` workaround
replace.(Showoff.showoff(x), r"-(?=\d)" => MINUS_SIGN)
if !isempty(x)
replace.(Showoff.showoff(x), r"-(?=\d)" => MINUS_SIGN)
else
x

Check warning on line 716 in src/makielayout/lineaxis.jl

View check run for this annotation

Codecov / codecov/patch

src/makielayout/lineaxis.jl#L716

Added line #L716 was not covered by tests
end
end

# identity or unsupported scales
Expand Down
4 changes: 4 additions & 0 deletions test/makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ end

@test get_ticks(WilkinsonTicks(5), identity, automatic, 1, 5) == ([1, 2, 3, 4, 5], ["1", "2", "3", "4", "5"])
end
#Check that ticks outside supplied limits are filtered out
ticks = [-0.2, 0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
limits = (0.0, 0.6)
@test get_ticks(ticks, identity, automatic, limits...) == ([0.0, 0.2, 0.4, 0.6], ["0.0", "0.2", "0.4", "0.6"])
end

@testset "MultiplesTicks strip_zero" begin
Expand Down
Loading