StackOverflowError with boxplot!() due to deprecation

I’d like to have boxplot only considering non-missing data ignoring row informations.

using StatsPlots
a=[ 0.000163187  0.000121895  0.000229244  6.98374e-6
         missing      missing      missing      missing
        0.000347736  0.000385244  0.00025956    missing]

function boxplot_missing(x::Any, y::Array{Union{Missing, Float64}})
    for i in 1:size(y,2)
        plot_y = filter(!ismissing, y[:,i])
        if i==1
            bp=boxplot([i],plot_y)
        else
            boxplot!([i],plot_y)
        end
    end
    display(bp)
end

boxplot_missing(1:4, a)

but get the error. When I click in the .\boot.jl and .\array.jl, it’s reported to be deprecated by Atom. I ran out of ideas on what I can work on. Any suggestions are much appreciated.

ERROR: StackOverflowError:
Stacktrace:
 [1] Array at .\boot.jl:405 [inlined]
 [2] Array at .\boot.jl:414 [inlined]
 [3] similar at .\array.jl:361 [inlined]
 [4] similar at .\abstractarray.jl:626 [inlined]
 [5] _unsafe_getindex(::IndexLinear, ::Array{Union{Missing, Float64},1}, ::Base.Slice{Base.OneTo{Int64}}, ::Int64) at
.\multidimensional.jl:739
 [6] _getindex at .\multidimensional.jl:727 [inlined]
 [7] getindex at .\abstractarray.jl:980 [inlined]
 [8] boxplot(::Array{Int64,1}, ::Array{Union{Missing, Float64},1}) at H:\julia\ngsJulia\ngsPool\compare\compare_ngsPool_snape.jl:138
 [9] boxplot(::Array{Int64,1}, ::Array{Union{Missing, Float64},1}) at H:\julia\ngsJulia\ngsPool\compare\compare_ngsPool_snape.jl:140 (repeats 21741 times)
 [10] boxplot_missing(::UnitRange{Int64}, ::Array{Union{Missing, Float64},2}) at H:\julia\ngsJulia\ngsPool\compare\compare_ngsPool_snape.jl:140
 [11] top-level scope at none:0

I’ve got another error, so I rearranged (quick and dirty) your code a bit and this seems to work as expected (Julia 1.5):

function boxplot_missing(x::Any, y::Array{Union{Missing, Float64}})
	i=1
    plot_y = filter(!ismissing, y[:,i])
    bp=boxplot([i],plot_y)
    for i in 2:size(y,2)
		plot_y = filter(!ismissing, y[:,i])
		bp=boxplot!([i],plot_y)
    end
    display(bp)
end

By the way: x is not used… and some other minor details off topic :slight_smile:

Thanks, I tried your codes but still got the same errors. Mine is Julia Version 1.4.0.

I tried in 1.4.2 and it works. Is this an oppurtunity to upgrade?

Some minor rework:


using StatsPlots

function boxplot_missing(m)
    bp=boxplot()
    for i in 1:size(m,2)
		bp=boxplot!(filter(!ismissing,m[:,i]))
    end
    display(bp)
end

a=[ 0.000163187  0.000121895  0.000229244  6.98374e-6
	missing      missing      missing      missing
	0.000347736  0.000385244  0.00025956   missing]
			   
boxplot_missing(a)

Works in Julia 1.3.1, 1.4.2 and 1.5.0.

1 Like

Thanks for the information and your time.

Could you specify a bit, if at your convenience? I used ::Any to cope with uncertain input including 1:4 or other vector. May I know your suggestion?

See above…

Complementary information: after update all the packages (type ]update in atom), this example also works perfectly in julia 1.4.

2 Likes