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

Support for disabling axis ticks in UnicodePlots #4681

Merged
merged 4 commits into from
Mar 6, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/axes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ get_ticks(ticks::Bool, args...) =
get_ticks(::T, args...) where {T} =
throw(ArgumentError("Unknown ticks type in get_ticks: $T"))

# do not specify array item type to also catch e.g. "xlabel=[]" and "xlabel=([],[])"
_has_ticks(v::AVec) = !isempty(v)
_has_ticks(t::Tuple{AVec,AVec}) = !isempty(t[1])
_has_ticks(s::Symbol) = s !== :none
_has_ticks(b::Bool) = b
_has_ticks(::Nothing) = false
_has_ticks(::Any) = true

has_ticks(axis::Axis) = get(axis, :ticks, nothing) |> _has_ticks

_transform_ticks(ticks, axis) = ticks
_transform_ticks(ticks::AbstractArray{T}, axis) where {T<:Dates.TimeType} =
Dates.value.(ticks)
Expand Down
2 changes: 2 additions & 0 deletions src/backends/unicodeplots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ function _before_layout_calcs(plt::Plot{UnicodePlotsBackend})
yscale = yaxis[:scale],
xflip = xaxis[:flip],
yflip = yaxis[:flip],
xticks = has_ticks(xaxis),
yticks = has_ticks(yaxis),
border,
height,
width,
Expand Down