Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace radial_distortion_threshhold with directly setting radius_at_…
…origin (#3381) # Description Fixes #3375 by allowing users to set a radial offset that can be used to map a negative rmin to 0. E.g.: ```julia pow2db(x) = 20log10(x) theta_prime = pi angle(a,b) = min(abs(a-b), 2π-abs(a-b)) gain(theta) = abs(sinc(2.0*angle(theta,theta_prime))) thetas = range(0, 2pi, length=361) rs = pow2db.(gain.(thetas)) f_polar = Figure() ax_polar_lin = PolarAxis(f_polar[1,1], title="Gain") lines!(ax_polar_lin, thetas, gain.(thetas)) ax_polar_dB = PolarAxis(f_polar[1,2], title="Gain in dB", radius_at_origin = -80) lines!(ax_polar_dB, thetas, rs) f_polar ``` ![Screenshot from 2023-11-17 14-46-38](https://github.com/MakieOrg/Makie.jl/assets/10947937/d3933529-0705-4a28-844e-27dfbce9f6ff) Some open questions: - Should negative rlimits automatically result in radii getting shifted? - Should zooming be allowed to change `radius_at_origin`? - Should we adjust `theta_0` to work like r0/radius_at_origin? Currently we have `theta_out = theta_in + theta_0` and `r_out = r_in - r0` Note that offsetting radii results in distortions: ```julia phis = range(pi/4, 9pi/4, length=201) rs = 1.0 ./ sin.(range(pi/4, 3pi/4, length=51)[1:end-1]) rs = vcat(rs, rs, rs, rs, rs[1]) fig = Figure() ax = PolarAxis(fig[1, 1], radius_at_origin = -2) lines!(ax, phis, rs) ax = PolarAxis(fig[1, 2]) lines!(ax, phis, rs) ax = PolarAxis(fig[1, 3], radius_at_origin = 0.5) lines!(ax, phis, rs) fig ``` ![Screenshot from 2023-11-17 14-57-01](https://github.com/MakieOrg/Makie.jl/assets/10947937/a6390ba2-526d-4fcb-8702-69e8d89e206f) ## Changes - replace `radial_distortion_threshold` with `radius_at_origin` which allows you to set an offset for radii - add `clip_r::Bool` to PolarAxis and Polar transform, allowing you to set whether to enforce $r \ge 0$ or not - for `clip_r = true` (old behavior) return `NaN` rather than `r = 0` if $r < 0$. ## Type of change - [x] (Somewhat minor) Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Checklist - [x] Added an entry in NEWS.md (for new features and breaking changes) - [x] Added or changed relevant sections in the documentation - [x] Added unit tests for new algorithms, conversion methods, etc. - [x] Added reference image tests for new plotting functions, recipes, visual options, etc.
- Loading branch information
Showing
9 changed files
with
203 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.