boxplot

Makie.boxplotFunction
boxplot(x, y; kwargs...)

Draw a Tukey style boxplot. The boxplot has 3 components:

  • a crossbar spanning the interquartile (IQR) range with a midline marking the median
  • an errorbar whose whiskers span range * iqr
  • points marking outliers, that is, data outside the whiskers

Arguments

  • x: positions of the categories
  • y: variables within the boxes

Keywords

  • orientation=:vertical: orientation of box (:vertical or :horizontal)
  • width=0.8: width of the box
  • show_notch=false: draw the notch
  • notchwidth=0.5: multiplier of width for narrowest width of notch
  • show_median=true: show median as midline
  • range: multiple of IQR controlling whisker length
  • whiskerwidth: multiplier of width for width of T's on whiskers, or :match to match width
  • show_outliers: show outliers as points
source

Examples

using CairoMakie

xs = rand(1:3, 1000)
ys = randn(1000)

boxplot(xs, ys)
using CairoMakie

xs = rand(1:3, 1000)
ys = randn(1000)
dodge = rand(1:2, 1000)

boxplot(xs, ys, dodge = dodge, show_notch = true, color = dodge)

Colors are customizable. The color attribute refers to the color of the boxes, whereas outliercolor refers to the color of the outliers. If not scalars (e.g. :red), these attributes must have the length of the data. If outliercolor is not provided, outliers will have the same color as their box, as shown above.

Note

For all indices corresponding to points within the same box, color (but not outliercolor) must have the same value.

using CairoMakie

xs = rand(1:3, 1000)
ys = randn(1000)
dodge = rand(1:2, 1000)

boxplot(xs, ys, dodge = dodge, show_notch = true, color = map(d->d==1 ? :blue : :red, dodge) , outliercolor = rand([:red, :green, :blue, :black, :yellow], 1000))