Adds radial data filtering for points within axis limits.
This commit is contained in:
parent
08a6f3af36
commit
8bbdb0f1b8
@ -221,7 +221,8 @@ function pgf_series(sp::Subplot, series::Series)
|
|||||||
# See "Scatter Plots" in PGFPlots documentation
|
# See "Scatter Plots" in PGFPlots documentation
|
||||||
d[:x], d[:y], d[:marker_z]
|
d[:x], d[:y], d[:marker_z]
|
||||||
elseif ispolar(sp)
|
elseif ispolar(sp)
|
||||||
rad2deg.(d[:x]), d[:y]
|
theta, r = filter_radial_data(d[:x], d[:y], axis_limits(sp[:yaxis]))
|
||||||
|
rad2deg.(theta), r
|
||||||
else
|
else
|
||||||
d[:x], d[:y]
|
d[:x], d[:y]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -717,8 +717,9 @@ end
|
|||||||
function plotly_polar!(d_out::KW, series::Series)
|
function plotly_polar!(d_out::KW, series::Series)
|
||||||
# convert polar plots x/y to theta/radius
|
# convert polar plots x/y to theta/radius
|
||||||
if ispolar(series[:subplot])
|
if ispolar(series[:subplot])
|
||||||
d_out[:t] = rad2deg.(pop!(d_out, :x))
|
theta, r = filter_radial_data(pop!(d_out, :x), pop!(d_out, :y), axis_limits(series[:subplot][:yaxis]))
|
||||||
d_out[:r] = pop!(d_out, :y)
|
d_out[:t] = rad2deg.(theta)
|
||||||
|
d_out[:r] = r
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
23
src/utils.jl
23
src/utils.jl
@ -363,15 +363,26 @@ end
|
|||||||
|
|
||||||
function convert_to_polar(x, y, r_extrema = calc_r_extrema(x, y))
|
function convert_to_polar(x, y, r_extrema = calc_r_extrema(x, y))
|
||||||
rmin, rmax = r_extrema
|
rmin, rmax = r_extrema
|
||||||
phi, r = x, y
|
theta, r = filter_radial_data(x, y, r_extrema)
|
||||||
r = (r - rmin) / (rmax - rmin)
|
r = (r - rmin) / (rmax - rmin)
|
||||||
n = max(length(phi), length(r))
|
x = r.*cos.(theta)
|
||||||
x = zeros(n)
|
y = r.*sin.(theta)
|
||||||
y = zeros(n)
|
x, y
|
||||||
|
end
|
||||||
|
|
||||||
|
# Filters radial data for points within the axis limits
|
||||||
|
function filter_radial_data(theta, r, r_extrema::Tuple{Real, Real})
|
||||||
|
n = max(length(theta), length(r))
|
||||||
|
rmin, rmax = r_extrema
|
||||||
|
x, y = zeros(n), zeros(n)
|
||||||
for i in 1:n
|
for i in 1:n
|
||||||
x[i] = _cycle(r,i) * cos.(_cycle(phi,i))
|
x[i] = _cycle(theta, i)
|
||||||
y[i] = _cycle(r,i) * sin.(_cycle(phi,i))
|
y[i] = _cycle(r, i)
|
||||||
end
|
end
|
||||||
|
points = map((a, b) -> (a, b), x, y)
|
||||||
|
filter!(a -> a[2] >= rmin && a[2] <= rmax, points)
|
||||||
|
x = map(a -> a[1], points)
|
||||||
|
y = map(a -> a[2], points)
|
||||||
x, y
|
x, y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user