Fix for plotting a vector of (at least two) NaNs
This commit is contained in:
parent
57ba6aa5a9
commit
0c7f7ba011
22
src/utils.jl
22
src/utils.jl
@ -82,7 +82,7 @@ function series_segments(series::Series, seriestype::Symbol = :path)
|
|||||||
args = RecipesPipeline.is3d(series) ? (x, y, z) : (x, y)
|
args = RecipesPipeline.is3d(series) ? (x, y, z) : (x, y)
|
||||||
nan_segments = collect(iter_segments(args...))
|
nan_segments = collect(iter_segments(args...))
|
||||||
|
|
||||||
result = if has_attribute_segments(series)
|
segments = if has_attribute_segments(series)
|
||||||
Iterators.flatten(map(nan_segments) do r
|
Iterators.flatten(map(nan_segments) do r
|
||||||
if seriestype in (:scatter, :scatter3d)
|
if seriestype in (:scatter, :scatter3d)
|
||||||
(SeriesSegment(i:i, i) for i in r)
|
(SeriesSegment(i:i, i) for i in r)
|
||||||
@ -94,8 +94,14 @@ function series_segments(series::Series, seriestype::Symbol = :path)
|
|||||||
(SeriesSegment(r, 1) for r in nan_segments)
|
(SeriesSegment(r, 1) for r in nan_segments)
|
||||||
end
|
end
|
||||||
|
|
||||||
seg_range = UnitRange(minimum(first(seg.range) for seg in result),
|
warn_on_attr_dim_mismatch(series, x, y, z, segments)
|
||||||
maximum(last(seg.range) for seg in result))
|
return segments
|
||||||
|
end
|
||||||
|
|
||||||
|
function warn_on_attr_dim_mismatch(series, x, y, z, segments)
|
||||||
|
isempty(segments) && return
|
||||||
|
seg_range = UnitRange(minimum(first(seg.range) for seg in segments),
|
||||||
|
maximum(last(seg.range) for seg in segments))
|
||||||
for attr in _segmenting_vector_attributes
|
for attr in _segmenting_vector_attributes
|
||||||
v = get(series, attr, nothing)
|
v = get(series, attr, nothing)
|
||||||
if v isa AVec && eachindex(v) != seg_range
|
if v isa AVec && eachindex(v) != seg_range
|
||||||
@ -111,8 +117,6 @@ function series_segments(series::Series, seriestype::Symbol = :path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# helpers to figure out if there are NaN values in a list of array types
|
# helpers to figure out if there are NaN values in a list of array types
|
||||||
@ -174,14 +178,6 @@ makevec(v::T) where {T} = T[v]
|
|||||||
maketuple(x::Real) = (x,x)
|
maketuple(x::Real) = (x,x)
|
||||||
maketuple(x::Tuple{T,S}) where {T,S} = x
|
maketuple(x::Tuple{T,S}) where {T,S} = x
|
||||||
|
|
||||||
for i in 2:4
|
|
||||||
@eval begin
|
|
||||||
RecipesPipeline.unzip(
|
|
||||||
v::Union{AVec{<:Tuple{Vararg{T,$i} where T}}, AVec{<:GeometryBasics.Point{$i}}},
|
|
||||||
) = $(Expr(:tuple, (:([t[$j] for t in v]) for j=1:i)...))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
RecipesPipeline.unzip(
|
RecipesPipeline.unzip(
|
||||||
::Union{AVec{<:GeometryBasics.Point{N}}, AVec{<:Tuple{Vararg{T,N} where T}}}
|
::Union{AVec{<:GeometryBasics.Point{N}}, AVec{<:Tuple{Vararg{T,N} where T}}}
|
||||||
) where N = error("$N-dimensional unzip not implemented.")
|
) where N = error("$N-dimensional unzip not implemented.")
|
||||||
|
|||||||
@ -172,6 +172,8 @@ end
|
|||||||
@testset "Plot" begin
|
@testset "Plot" begin
|
||||||
plots = [histogram([1, 0, 0, 0, 0, 0]),
|
plots = [histogram([1, 0, 0, 0, 0, 0]),
|
||||||
plot([missing]),
|
plot([missing]),
|
||||||
|
plot([missing, missing]),
|
||||||
|
plot(fill(missing, 10)),
|
||||||
plot([missing; 1:4]),
|
plot([missing; 1:4]),
|
||||||
plot([fill(missing, 10); 1:4]),
|
plot([fill(missing, 10); 1:4]),
|
||||||
plot([1 1; 1 missing]),
|
plot([1 1; 1 missing]),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user