From e9cd69ea2ff3e663ab1101b3eec863a6fe1d110f Mon Sep 17 00:00:00 2001 From: yha Date: Mon, 1 Mar 2021 02:17:42 +0200 Subject: [PATCH] Fix Shape vector recipe --- src/components.jl | 12 ++++-------- src/recipes.jl | 10 ++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components.jl b/src/components.jl index 00ca51e6..b0a76167 100644 --- a/src/components.jl +++ b/src/components.jl @@ -42,15 +42,11 @@ function coords(shape::Shape) shape.x, shape.y end +#coords(shapes::AVec{Shape}) = unzip(map(coords, shapes)) function coords(shapes::AVec{Shape}) - length(shapes) == 0 && return zeros(0), zeros(0) - xs = map(get_xs, shapes) - ys = map(get_ys, shapes) - x, y = map(copy, coords(shapes[1])) - for shape in shapes[2:end] - nanappend!(x, shape.x) - nanappend!(y, shape.y) - end + c = map(coords, shapes) + x = [q[1] for q in c] + y = [q[2] for q in c] x, y end diff --git a/src/recipes.jl b/src/recipes.jl index 46ef79a1..dcf5fc8d 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -1364,6 +1364,16 @@ end @recipe function f(shapes::AVec{Shape}) seriestype --> :shape + # For backwards compatibility, column vectors of segmenting attributes are + # interpreted as having one element per shape + for attr in union(_segmenting_array_attributes, _segmenting_vector_attributes) + v = get(plotattributes, attr, nothing) + if v isa AVec || v isa AMat && size(v,2) == 1 + @warn "Column vector attribute `$attr` reinterpreted as row vector (one value per shape).\n" * + "Pass a row vector instead (e.g. using `permutedims`) to suppress this warning." + plotattributes[attr] = permutedims(v) + end + end coords(shapes) end