-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
PolarAxis unable to set negative rlimits #3375
Comments
We experimented with offsetting radii so that r_in > 0 ends up at r_out = 0 to increase the space a plot limited to a ring (sector) occupies. (I.e. with rmax > rmin >> 0.) That's what Ultimately this won't help you, since it is restricted to r0 > 0. I also don't think you can hack this by setting r0 in But there is still some functionality for this in the background and I think replacing If you want to try making these changes you could remove Makie.jl/src/makielayout/blocks/polaraxis.jl Lines 225 to 230 in 531d42d
and make radius_at_origin (the r0) an attribute of the PolarAxis by adding it hereMakie.jl/src/makielayout/types.jl Lines 1690 to 1696 in 531d42d
The radial_distortion_threshold further above should be removed as well.
|
…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.
]activate --temp; add Makie
)Issue
It looks like PolarAxis does not support setting negative r limits or plotting lines with negative values. Polar plots are used frequently in electrical engineering to present things like antenna gain patterns, measured on a dB scale (Example).
I demonstrated this with the MWE below, plotting a fake gain pattern in linear and dB scales on both a regular
Axis
and aPolarAxis
. The polar plot in dB scale won't display any of the line because it's always <= 0. If I try to setrlimits
to the appropriate range for this plot, e.g.rlimits=(-40,0)
the r axis looks like a mess with no ticks remaining.Minimum Working Example
The text was updated successfully, but these errors were encountered: