# 箱线图

箱线图（box plot），又称箱须图，是一种统计图形，用五个数值概括连续变量的分布：中位数、第一和第三四分位数（即箱体的两端），以及两条须，分别延伸至距四分位数固定距离内最极端的数据值。须之外的值以单独的点绘出。今天通用的形式源自约翰·图基（John Tukey）在《探索性数据分析》（*Exploratory Data Analysis*，1977）中定义的“示意图”，是最常用的统计图形之一。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup><sup> • </sup><sup>[2](https://vita.had.co.nz/papers/boxplots.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 展示内容 | 中位数、两个折叶（四分位数）、两条须，以及所有“离群”点逐一绘出<sup>[3](https://ggplot2.tidyverse.org/reference/geom_boxplot.html)</sup> |
| 箱体 | 横跨第25至第75百分位数，代表数据的中间50%<sup>[4](https://www.itl.nist.gov/div898/handbook/eda/section3/boxplot.htm)</sup> |
| 须的规则 | 每条须延伸至距其折叶不超过1.5×IQR的最大或最小观测值；须之外的数据逐一绘出<sup>[3](https://ggplot2.tidyverse.org/reference/geom_boxplot.html)</sup> |
| 带凹槽变体 | 凹槽延伸1.58×IQR/√n，为比较中位数提供约95%的置信区间（麦吉尔、图基与拉森，1978）<sup>[3](https://ggplot2.tidyverse.org/reference/geom_boxplot.html)</sup><sup> • </sup><sup>[5](https://doi.org/10.1080/00031305.1978.10479236)</sup> |
| 起源 | 图基在《探索性数据分析》（1977）中定义了“箱须图”和“示意图”；类似的极差条形图曾出现于玛丽·埃莉诺·斯皮尔（Mary Eleanor Spear）的《统计图表》（*Charting Statistics*，1952）<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup> |
| 主要优势 | 使用稳健统计量（中位数与IQR）比较各组分布，且这些统计量位于实际数据点上<sup>[2](https://vita.had.co.nz/papers/boxplots.pdf)</sup> |
| 主要局限 | 当数据包含多个总体（如双峰数据）时，单个箱线图可能产生误导<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup><sup> • </sup><sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC5010052/)</sup> |

## 构造

标准构造分三步进行。第一，计算中位数和四分位数，即第25和第75百分位数。第二，在中位数处画一条线，在四分位数之间画一个箱体；该箱体代表数据的中间50%。第三，从每个四分位数向数据的极端点画线。<sup>[4](https://www.itl.nist.gov/div898/handbook/eda/section3/boxplot.htm)</sup>

四分位数之间的距离即四分位距（IQR）。在大多数软件采用的图基约定中，上须从上折叶延伸至超出其不超过1.5×IQR的最大值，下须对称延伸；须之外的观测值称为“离群”点，逐一绘出。<sup>[3](https://ggplot2.tidyverse.org/reference/geom_boxplot.html)</sup>图基自己的术语将“内栅栏”定在四分位点±1.5倍F扩展处，将“外栅栏”定在±3.0倍F扩展处，栅栏之间的点标记为“在外”，外栅栏之外的点标记为“远外”。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup>一个相关的变体将须画在3×IQR处，作为筛查疑似离群值的步骤。<sup>[7](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=957454)</sup>

乘数1.5是一种约定，而非推导出的常数。对于完全正态分布的数据，预计约有0.70%的个案（大约每150个中有1个）落在栅栏之外，每个方向约各占一半。<sup>[8](https://repository.iit.edu/islandora/object/islandora%3A1012018/datastream/OBJ/download/Experimental_Design_and_Analysis.pdf)</sup>由于该规则不考虑样本量，被标记为离群值的点数随样本增大而增加，已有若干修改方案被提出以调整栅栏。<sup>[9](https://arxiv.org/abs/2510.20259)</sup>

## 目的与用途

箱线图传达数据集中的位置和变异信息，尤其用于检测和展示不同组之间的变化。NIST/SEMATECH手册列出了箱线图能回答的问题：某因素是否显著、子组间位置是否有差异、子组间变异是否有差异，以及是否存在离群值。<sup>[4](https://www.itl.nist.gov/div898/handbook/eda/section3/boxplot.htm)</sup>

**比较是其主要优势。** 图基认为比较两个或多个数据批次是箱线图最适合的用途，且箱线图使用稳健的汇总统计量——中位数和IQR，而非均值和标准差——这些统计量总是位于实际数据点上，计算快捷，且没有可调参数。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup><sup> • </sup><sup>[2](https://vita.had.co.nz/papers/boxplots.pdf)</sup>当多个组并排绘制时，箱体宽度可按各组点数成比例设定，或视软件而定将所有箱体画成相同宽度。<sup>[4](https://www.itl.nist.gov/div898/handbook/eda/section3/boxplot.htm)</sup>

带凹槽变体增添了推断元素：如果两个箱体的凹槽不重叠，则提示中位数存在显著差异。<sup>[3](https://ggplot2.tidyverse.org/reference/geom_boxplot.html)</sup>Matplotlib默认按麦吉尔、图基与拉森（1978）的高斯渐近近似计算凹槽位置，或通过对中位数进行自助法（建议1,000至10,000次重抽样）计算，并允许直接覆盖区间。<sup>[10](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html)</sup>

## 历史

这种图形形式早于图基。贝尔实验室（Bell Labs）展示研究部经理肯尼思·W·海默（Kenneth W. Haemer）于1948年在《美国统计学家》（*The American Statistician*）上发表“极差条形图”，展示了从最小值到最大值的箱体，并在样本均值处画一条线。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup>美国图形专家玛丽·埃莉诺·斯皮尔（Mary Eleanor Spear，1897–1986）在其1952年教科书《统计图表》中发表了一种极差条形图，从第25至第75百分位数画一个箱体，附中位数线，并画线延伸至最小值和最大值；数十年来功劳归于图基，数据可视化界的一场运动已开始恢复对斯皮尔优先权的承认。<sup>[11](https://fisherdigitus.library.utoronto.ca/exhibits/show/emerging-patterns--data-visual/iv--bars--lines--boxes/----innovations-in-lines-and-b)</sup><sup> • </sup><sup>[12](https://academic.oup.com/jrssig/article/22/3/31/8099019)</sup>

图基的贡献在于选择了适用于广泛数据的汇总统计量，并将它们精确地对应到视觉组件上，使得任何人为同一数据绘制箱线图都会得到完全相同的显示。他1977年的书首先定义了“箱须图”——展示五数概括，须延伸至极端值——然后定义了“示意图”，后者增加了栅栏规则；示意图后来被简称为箱线图，是今天最常用的版本。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup>

## 软件差异

各实现在细节上并不一致。弗里格（Frigge）、霍格林（Hoaglin）与伊格莱维奇（Iglewicz）（1989）告诫说，统计软件包对用于箱体边缘的四分位数往往有自己的定义，导致“标准”箱线图出现不同版本，并建议用户特别注意了解使用了哪些算法。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup>这些差异在小样本中最为明显。ggplot2指出，其折叶按25%和75%分位数计算，与R基础`boxplot()`函数所用方法略有不同。<sup>[3](https://ggplot2.tidyverse.org/reference/geom_boxplot.html)</sup>Matplotlib则允许将须的位置设为百分位数对，因此`whis = (0, 100)`可覆盖数据的整个范围。<sup>[10](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html)</sup>

## 变体与替代方案

自1978年以来出现了许多扩展。由麦吉尔、图基与拉森设计的可变宽度箱线图和带凹槽箱线图，为显示增添了组大小和中位数差异的粗略显著性。<sup>[5](https://doi.org/10.1080/00031305.1978.10479236)</sup>爱德华·塔夫特（Edward Tufte）提议完全去掉箱体，只保留中位数的点和须，以减少他所称的“数据墨水”；知觉研究发现这种变体比原版准确度低得多。<sup>[2](https://vita.had.co.nz/papers/boxplots.pdf)</sup>后来的提议增加了表示偏度和峰度的阴影、密度估计，以及对加权、环状、函数型和双变量数据的适配，包括袋图——一种双变量箱线图。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup>

混合图表将箱线图与密度信息结合。小提琴图将镜像密度轨迹与箱线图类信息（如中位数、IQR和栅栏）叠加，展示整个分布形状。<sup>[13](https://pmc.ncbi.nlm.nih.gov/articles/PMC7221239/)</sup>豆图在一维散点图中以短线显示各个观测值，并附估计密度，使双峰分布和重复的测量值等异常易于发现。<sup>[14](https://www.jstatsoft.org/article/view/v028c01)</sup>

**箱线图何时产生误导。** 由于该图依赖少数汇总统计量，它不适用于包含两个不同子总体的双峰数据集；对此类数据，显示实际观测值的图（如蜂群图或直方图）信息更丰富。<sup>[6](https://pmc.ncbi.nlm.nih.gov/articles/PMC5010052/)</sup>图基自己用瑞利勋爵（Lord Rayleigh）的氮重量数据说明了这个问题：单个箱线图掩盖了来自不同氮源的三个测量组，他建议在可能存在多个总体时，小数据集用点图，大数据集用分位数-分位数图。<sup>[1](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)</sup>

## References

1. [Kafadar, Karen. "Boxplots: Definition, History, Extensions, and Examples." WIREs Computational Statistics (2026).](https://wires.onlinelibrary.wiley.com/doi/10.1002/wics.70073)
2. [Wickham, Hadley, and Lisa Stryjewski. "40 years of boxplots."](https://vita.had.co.nz/papers/boxplots.pdf)
3. ["A box and whiskers plot (in the style of Tukey) — geom_boxplot." ggplot2 documentation.](https://ggplot2.tidyverse.org/reference/geom_boxplot.html)
4. ["1.3.3.7. Box Plot." NIST/SEMATECH e-Handbook of Statistical Methods.](https://www.itl.nist.gov/div898/handbook/eda/section3/boxplot.htm)
5. [McGill, Robert, John W. Tukey, and Wayne A. Larsen. "Variations of Box Plots." The American Statistician 32, no. 1 (1978): 12–16.](https://doi.org/10.1080/00031305.1978.10479236)
6. ["Statistical relevance—relevant statistics, part II: presenting experimental data." PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC5010052/)
7. [NIST Internal Report 8526.](https://tsapps.nist.gov/publication/get_pdf.cfm?pub_id=957454)
8. [Experimental Design and Analysis, Chapter 4: Exploratory Data Analysis.](https://repository.iit.edu/islandora/object/islandora%3A1012018/datastream/OBJ/download/Experimental_Design_and_Analysis.pdf)
9. ["Unifying Boxplots: A Multiple Testing Perspective." arXiv.](https://arxiv.org/abs/2510.20259)
10. ["matplotlib.pyplot.boxplot." Matplotlib 3.11.2 documentation.](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html)
11. ["Innovations in Lines and Boxes." Emerging Patterns: Data Visualization Through History, Thomas Fisher Rare Book Library.](https://fisherdigitus.library.utoronto.ca/exhibits/show/emerging-patterns--data-visual/iv--bars--lines--boxes/----innovations-in-lines-and-b)
12. ["Mary Eleanor Spear: Putting the art into charting." Significance, Royal Statistical Society.](https://academic.oup.com/jrssig/article/22/3/31/8099019)
13. ["Descriptive Statistics for Summarising Data." PMC.](https://pmc.ncbi.nlm.nih.gov/articles/PMC7221239/)
14. [Kampstra, Peter. "Beanplot: A Boxplot Alternative for Visual Comparison of Distributions." Journal of Statistical Software (2008).](https://www.jstatsoft.org/article/view/v028c01)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 统计学与概率论 › Applied, official, and domain statistics › Computational statistics › Statistical graphics and computational data visualization

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/box-plot

English original: https://www.edgepedia.org/box-plot
