fix for vectors containing missing

This commit is contained in:
Daniel Schwabeneder 2020-03-18 01:43:42 +01:00
parent b60007cde9
commit f606f083a4

View File

@ -180,14 +180,16 @@ _apply_type_recipe(plotattributes, v) = RecipesBase.apply_recipe(plotattributes,
function _apply_type_recipe(plotattributes, v::AbstractArray) function _apply_type_recipe(plotattributes, v::AbstractArray)
# First we try to apply an array type recipe. # First we try to apply an array type recipe.
w = RecipesBase.apply_recipe(plotattributes, typeof(v), v)[1].args[1] w = RecipesBase.apply_recipe(plotattributes, typeof(v), v)[1].args[1]
# If it did not change try it element-wise # If the type did not change try it element-wise
if v == w if typeof(v) == typeof(w)
isempty(skipmissing(v)) && return Float64[] isempty(skipmissing(v)) && return Float64[]
x = first(skipmissing(v)) x = first(skipmissing(v))
args = RecipesBase.apply_recipe(plotattributes, typeof(x), x)[1].args args = RecipesBase.apply_recipe(plotattributes, typeof(x), x)[1].args
if length(args) == 2 && all(arg -> arg isa Function, args) if length(args) == 2 && all(arg -> arg isa Function, args)
numfunc, formatter = args numfunc, formatter = args
return Formatted(map(numfunc, v), formatter) return Formatted(map(numfunc, v), formatter)
else
return v
end end
end end
return w return w