Skip to content

Commit

Permalink
Add option strip_zero for MultiplesTicks
Browse files Browse the repository at this point in the history
  • Loading branch information
tuncbkose committed Sep 17, 2024
1 parent c463049 commit a24ea35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/makielayout/lineaxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,13 @@ function get_ticks(m::MultiplesTicks, any_scale, ::Automatic, vmin, vmax)
dvmax = vmax / m.multiple
multiples = Makie.get_tickvalues(LinearTicks(m.n_ideal), dvmin, dvmax)

multiples .* m.multiple, showoff_minus(multiples) .* m.suffix
locs = multiples .* m.multiple
labs = showoff_minus(multiples) .* m.suffix
if m.strip_zero
labs = map(x -> x[1] != '0' ? x : "0", labs)
end

return locs, labs
end

function get_ticks(m::AngularTicks, any_scale, ::Automatic, vmin, vmax)
Expand Down
7 changes: 7 additions & 0 deletions src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,20 @@ that are multiples of pi, printed like "1π", "2π", etc.:
```
MultiplesTicks(5, pi, "π")
```
If `strip_zero == true`, then the resulting labels
will be checked and any label that is a multiple of 0
will be set to "0".
"""
struct MultiplesTicks
n_ideal::Int
multiple::Float64
suffix::String
strip_zero::Bool
end

MultiplesTicks(n_ideal, multiple, suffix) = MultiplesTicks(n_ideal, multiple, suffix, false)

"""
AngularTicks(label_factor, suffix[, n_ideal::Vector{Vec2f}])
Expand Down

0 comments on commit a24ea35

Please sign in to comment.