Merge pull request #3468 from yha/several-nans-fix
Fix for plotting a vector of (at least two) NaNs
This commit is contained in:
commit
61f2d825b6
14
src/utils.jl
14
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
|
||||||
|
|||||||
@ -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