# (boxplot, StatsPlots.jl) how to plot \`boxplot\` with different number of data for each label?

**URL:** https://discourse.julialang.org/t/boxplot-statsplots-jl-how-to-plot-boxplot-with-different-number-of-data-for-each-label/72649
**Category:** New to Julia
**Tags:** plots, nan, statsplots, missing-values
**Created:** [December 6, 2021, 11:22am UTC](https://discourse.julialang.org/t/boxplot-statsplots-jl-how-to-plot-boxplot-with-different-number-of-data-for-each-label/72649 "2021-12-06T11:22:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![iHany](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihany/32/18151_2.png) [@iHany](https://discourse.julialang.org/u/iHany)
#### Post date: [December 6, 2021, 11:22am UTC](https://discourse.julialang.org/t/boxplot-statsplots-jl-how-to-plot-boxplot-with-different-number-of-data-for-each-label/72649/1 "2021-12-06T11:22:56Z")

</div>

Hi,  
I’d like to plot a boxplot with different number of data for each label.

For example,

```julia
using StatsPlots

labels = ["hi", "hello"]
data = [1.0 missing 3.0; 4.0 5.0 6.0]
boxplot(labels, data)

```

results in the error:

```julia
julia> boxplot(labels, data)
ERROR: ArgumentError: quantiles are undefined in presence of NaNs or missing values
Stacktrace:
  [1] _quantilesort!(v::Vector{Union{Missing, Float64}}, sorted::Bool, minp::Float64, maxp::Float64)
    @ Statistics /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Statistics/src/Statistics.jl:980
  [2] #quantile!#49
    @ /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Statistics/src/Statistics.jl:957 [inlined]
  [3] quantile(v::Vector{Union{Missing, Float64}}, p::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64}; sorted::Bool, alpha::Float64, beta::Float64)
    @ Statistics /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Statistics/src/Statistics.jl:1073
  [4] quantile(v::Vector{Union{Missing, Float64}}, p::StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, Int64})
    @ Statistics /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/stdlib/v1.7/Statistics/src/Statistics.jl:1073
  [5] macro expansion
    @ ~/.julia/packages/StatsPlots/dFNaF/src/boxplot.jl:41 [inlined]
  [6] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{Val{:boxplot}}, x::Any, y::Any, z::Any)
    @ StatsPlots ~/.julia/packages/RecipesBase/qpxEX/src/RecipesBase.jl:289
  [7] _process_seriesrecipe(plt::Any, plotattributes::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/Bxu2O/src/series_recipe.jl:50
  [8] _process_seriesrecipes!(plt::Any, kw_list::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/Bxu2O/src/series_recipe.jl:27
  [9] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
    @ RecipesPipeline ~/.julia/packages/RecipesPipeline/Bxu2O/src/RecipesPipeline.jl:97
 [10] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
    @ Plots ~/.julia/packages/Plots/qbc7U/src/plot.jl:208
 [11] plot(::Any, ::Vararg{Any}; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Plots ~/.julia/packages/Plots/qbc7U/src/plot.jl:91
 [12] boxplot(::Any, ::Vararg{Any}; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
    @ Plots ~/.julia/packages/RecipesBase/qpxEX/src/RecipesBase.jl:410
 [13] boxplot(::Any, ::Vararg{Any})
    @ Plots ~/.julia/packages/RecipesBase/qpxEX/src/RecipesBase.jl:410
 [14] top-level scope
    @ REPL[18]:1

```

---

<div class="post-metadata">

### Author: ![iHany](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihany/32/18151_2.png) [@iHany](https://discourse.julialang.org/u/iHany)
#### Post date: [December 6, 2021, 11:43am UTC](https://discourse.julialang.org/t/boxplot-statsplots-jl-how-to-plot-boxplot-with-different-number-of-data-for-each-label/72649/2 "2021-12-06T11:43:03Z")

</div>

I found a remedy, included in [#471, StatsPlots.jl](https://github.com/JuliaPlots/StatsPlots.jl/issues/471).
