From b053366b060cadcb7e29ca16b7b3b1b9b4e625dc Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 26 Apr 2019 13:03:03 +0200 Subject: [PATCH] don't filter polar data --- src/backends/pgfplots.jl | 2 +- src/backends/plotly.jl | 2 +- src/utils.jl | 26 +------------------------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index 4f6d99af..a59fd19d 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -171,7 +171,7 @@ function pgf_series(sp::Subplot, series::Series) elseif st == :shape shape_data(series) elseif ispolar(sp) - theta, r = filter_radial_data(plotattributes[:x], plotattributes[:y], axis_limits(sp[:yaxis])) + theta, r = plotattributes[:x], plotattributes[:y] rad2deg.(theta), r else plotattributes[:x], plotattributes[:y] diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index dc06ed45..b642979f 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -774,7 +774,7 @@ end function plotly_polar!(plotattributes_out::KW, series::Series) # convert polar plots x/y to theta/radius if ispolar(series[:subplot]) - theta, r = filter_radial_data(pop!(plotattributes_out, :x), pop!(plotattributes_out, :y), axis_limits(series[:subplot][:yaxis])) + theta, r = pop!(plotattributes_out, :x), pop!(plotattributes_out, :y) plotattributes_out[:t] = rad2deg.(theta) plotattributes_out[:r] = r end diff --git a/src/utils.jl b/src/utils.jl index 7ae64796..2d8172f5 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -373,38 +373,14 @@ function heatmap_edges(v::AVec, scale::Symbol = :identity) map(invf, _heatmap_edges(map(f,v))) end -function calc_r_extrema(x, y) - xmin, xmax = ignorenan_extrema(x) - ymin, ymax = ignorenan_extrema(y) - r = 0.5 * NaNMath.min(xmax - xmin, ymax - ymin) - ignorenan_extrema(r) -end - -function convert_to_polar(x, y, r_extrema = calc_r_extrema(x, y)) +function convert_to_polar(theta, r, r_extrema = ignorenan_extrema(r)) rmin, rmax = r_extrema - theta, r = filter_radial_data(x, y, r_extrema) r = (r .- rmin) ./ (rmax .- rmin) x = r.*cos.(theta) y = r.*sin.(theta) 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 - x[i] = _cycle(theta, i) - y[i] = _cycle(r, i) - 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 -end - function fakedata(sz...) y = zeros(sz...) for r in 2:size(y,1)