Skip to content

Commit

Permalink
document WilkinsonTicks (#3819)
Browse files Browse the repository at this point in the history
Co-authored-by: laikq <[email protected]>
  • Loading branch information
t-bltg and laikq authored May 5, 2024
1 parent 714cf7a commit 08e0343
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## [Unreleased]

- Add `axislegend(ax, "title")` method [#3808](https://github.com/MakieOrg/Makie.jl/pull/3808)
- Document `WilkinsonTicks` [#3819](https://github.com/MakieOrg/Makie.jl/pull/3819).
- Add `axislegend(ax, "title")` method [#3808](https://github.com/MakieOrg/Makie.jl/pull/3808).
- Improved thread safety of rendering with CairoMakie (independent `Scene`s only) by locking FreeType handles [#3777](https://github.com/MakieOrg/Makie.jl/pull/3777).

## [0.20.9] - 2024-03-29
Expand Down
38 changes: 28 additions & 10 deletions src/makielayout/ticklocators/wilkinson.jl
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
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)],
"""
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)
niceness_weight = 1/4
)
`WilkinsonTicks` is a thin wrapper over `PlotUtils.optimize_ticks`, the docstring of which is reproduced below:
$(@doc PlotUtils.optimize_ticks)
"""
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,
Q = ticks.Q,
granularity_weight = ticks.granularity_weight,
simplicity_weight = ticks.simplicity_weight,
coverage_weight = ticks.coverage_weight,
niceness_weight = ticks.niceness_weight)
niceness_weight = ticks.niceness_weight
)

tickvalues
ticklocations
end
1 change: 0 additions & 1 deletion src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ struct WilkinsonTicks
simplicity_weight::Float64
coverage_weight::Float64
niceness_weight::Float64
min_px_dist::Float64
end

"""
Expand Down

0 comments on commit 08e0343

Please sign in to comment.