How should we do boxplots with small samples? This question is inspired by this posting, plus a comment by @StephanKolassa and an answer by @dipetkov who point out that the boxplots presented in that question are misleading. As is pointed out, boxplots display 5 summary statistics (the minimum, lower quartile, median, upper quartile, and maximum) of a sample; but in some instances, the sample size was only 2. It seems ridiculous to try to construct a 5-number "summary" of a sample of size 2. On the other side of the coin, if we have a sample of 100 observations, a boxplot clearly displays a summary of the data.
This led me to want to investigate what is done by popular R functions for constructing boxplots. Hence the example below for a simulated dataset with three groups and sample sizes 2, 5, and 15 respectively.
set.seed(42)
foo = data.frame(group = rep(1:3, c(2, 5, 15)), 
                 y = c(rnorm(2, mean = 2), rnorm(5, mean = 0), 
                       rnorm(15, mean = 1)))

# standard graphics
boxplot(y ~ group, data = foo)


# lattice graphics
library(lattice)

bwplot(~ y | group, data = foo)


# ggplot2 graphics
library(ggplot2)
ggplot(data = foo, aes(factor(group), y)) + geom_boxplot()


Created on 2022-07-19 by the reprex package (v2.0.1)
What we see is that in all three graphics methods -- standard, lattice, and ggplot -- the software glibly produces boxplots for all three groups.
So my question is

*

*Is it appropriate that boxplot software should construct a boxplot regardless of the sample size?

*If not, what should it do instead?


Just curious -- Looking outside of R with the same data...
Stata

SPSS

SAS Enterprise Guide

MATLAB (Statistics and Machine Learning tools)

Minitab
I was most curious about Minitab, but our virtual desktop access seemed to require a license. I'd be curious if somebody could fill this one in...
Summary
I see lots of different styles, some I like a whole lot better than others, but all programs tested were happy to make boxplots with 2 data values.
