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

document WilkinsonTicks #3819

Merged
merged 9 commits into from
May 5, 2024
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
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

Check warning on line 50 in src/makielayout/ticklocators/wilkinson.jl

View check run for this annotation

Codecov / codecov/patch

src/makielayout/ticklocators/wilkinson.jl#L50

Added line #L50 was not covered by tests
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
Loading