From a37a1a0004a1eb2b4fb4fba331b63cca5c19c6dc Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 12 Apr 2019 12:41:49 +0200 Subject: [PATCH 1/2] sort vector attributes for seriestype line --- src/recipes.jl | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/recipes.jl b/src/recipes.jl index 6f3fbdf0..220ab221 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -53,10 +53,41 @@ RecipesBase.apply_recipe(plotattributes::KW, ::Type{T}, plt::AbstractPlot) where # for seriestype `line`, need to sort by x values + +const POTENTIAL_VECTOR_ARGUMENTS = [ + :seriescolor, :seriesalpha, + :linecolor, :linealpha, :linewidth, :linestyle, :line_z, + :fillcolor, :fillalpha, :fill_z, + :markercolor, :markeralpha, :markershape, :marker_z, + :markerstrokecolor, :markerstrokealpha, + :yerror, :yerror, + :series_annotations, :fillrange +] + @recipe function f(::Type{Val{:line}}, x, y, z) indices = sortperm(x) x := x[indices] y := y[indices] + + # sort vector arguments + for arg in POTENTIAL_VECTOR_ARGUMENTS + if typeof(plotattributes[arg]) <: AVec + plotattributes[arg] = _cycle(plotattributes[arg], indices) + end + end + + # a tuple as fillrange has to be handed differently + if typeof(plotattributes[:fillrange]) <: Tuple + lower, upper = plotattributes[:fillrange] + if typeof(lower) <: AVec + lower = _cycle(lower, indices) + end + if typeof(upper) <: AVec + upper = _cycle(upper, indices) + end + plotattributes[:fillrange] = (lower, upper) + end + if typeof(z) <: AVec z := z[indices] end From 8a81b398cfc124cd5d0247dac55fb3bfbafe036e Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 12 Apr 2019 12:44:34 +0200 Subject: [PATCH 2/2] fix typo --- src/recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index 220ab221..ca2468e1 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -76,7 +76,7 @@ const POTENTIAL_VECTOR_ARGUMENTS = [ end end - # a tuple as fillrange has to be handed differently + # a tuple as fillrange has to be handled differently if typeof(plotattributes[:fillrange]) <: Tuple lower, upper = plotattributes[:fillrange] if typeof(lower) <: AVec