Skip to content

Commit

Permalink
document WilkinsonTicks
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Apr 30, 2024
1 parent 2a2a271 commit ce0e58f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
29 changes: 16 additions & 13 deletions src/makielayout/ticklocators/wilkinson.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
function WilkinsonTicks(k_ideal::Int; k_min = 2, k_max = 10,
Q = [(1.0,1.0), (5.0, 0.9), (2.0, 0.7), (2.5, 0.5), (3.0, 0.2)],
granularity_weight = 1/4,
simplicity_weight = 1/6,
coverage_weight = 1/3,
niceness_weight = 1/4,
min_px_dist = 50.0)

function WilkinsonTicks(
k_ideal::Int;
k_min = 2, k_max = 10,
Q = [(1.0, 1.0), (5.0, 0.9), (2.0, 0.7), (2.5, 0.5), (3.0, 0.2)],
granularity_weight = 1/4,
simplicity_weight = 1/6,
coverage_weight = 1/3,
niceness_weight = 1/4
)
if !(0 < k_min <= k_ideal <= k_max)
error("Invalid tick number specifications k_ideal $k_ideal, k_min $k_min, k_max $k_max")
end

WilkinsonTicks(k_ideal, k_min, k_max, Q, granularity_weight, simplicity_weight,
coverage_weight, niceness_weight, min_px_dist)
WilkinsonTicks(
k_ideal, k_min, k_max, Q, granularity_weight, simplicity_weight, coverage_weight, niceness_weight
)
end

get_tickvalues(ticks::WilkinsonTicks, vmin, vmax) = get_tickvalues(ticks, Float64(vmin), Float64(vmax))

function get_tickvalues(ticks::WilkinsonTicks, vmin::Float64, vmax::Float64)

tickvalues, _ = PlotUtils.optimize_ticks(Float64(vmin), Float64(vmax);
extend_ticks = false, strict_span=true, span_buffer = nothing,
ticklocations, _ = PlotUtils.optimize_ticks(
Float64(vmin), Float64(vmax);
extend_ticks = false, strict_span = true, span_buffer = nothing,
k_min = ticks.k_min,
k_max = ticks.k_max,
k_ideal = ticks.k_ideal,
Expand All @@ -29,5 +32,5 @@ function get_tickvalues(ticks::WilkinsonTicks, vmin::Float64, vmax::Float64)
coverage_weight = ticks.coverage_weight,
niceness_weight = ticks.niceness_weight)

tickvalues
ticklocations
end
26 changes: 15 additions & 11 deletions src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ struct LinearTicks
end
end

"""
Wilkinson's algorithm for positioning ticks.
$(@doc PlotUtils.optimize_ticks)
"""
struct WilkinsonTicks
k_ideal::Int
k_min::Int
Expand All @@ -56,7 +61,6 @@ struct WilkinsonTicks
simplicity_weight::Float64
coverage_weight::Float64
niceness_weight::Float64
min_px_dist::Float64
end

"""
Expand Down Expand Up @@ -93,17 +97,17 @@ struct AngularTicks
end
end

#=
"""
LogitTicks{T}(linear_ticks::T)

# """
# LogitTicks{T}(linear_ticks::T)

# Wraps any other tick object.
# Used to apply a linear tick searching algorithm on a logit-transformed interval.
# """
# struct LogitTicks{T}
# linear_ticks::T
# end
Wraps any other tick object.
Used to apply a linear tick searching algorithm on a logit-transformed interval.
"""
struct LogitTicks{T}
linear_ticks::T
end
=#

"""
LogTicks{T}(linear_ticks::T)
Expand Down

0 comments on commit ce0e58f

Please sign in to comment.