Fix Shape vector recipe

This commit is contained in:
yha 2021-03-01 02:17:42 +02:00
parent 65dac58338
commit e9cd69ea2f
2 changed files with 14 additions and 8 deletions

View File

@ -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

View File

@ -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