带最小/最大值须线的箱线图#

此示例展示了如何使用 2000 年美国人口数据创建一个箱线图。请注意,extent 属性的默认值为 1.5,这表示按照惯例将须线延伸到距离第一和第三四分位数 1.5 * IQR 范围内的最远点。

import altair as alt
from vega_datasets import data

source = data.population.url

alt.Chart(source).mark_boxplot(extent='min-max').encode(
    x='age:O',
    y='people:Q'
)
import altair as alt
from vega_datasets import data

source = data.population.url

alt.Chart(source).mark_boxplot(extent='min-max').encode(
    x='age:O',
    y='people:Q'
)
# No channel encoding options are specified in this chart
# so the code is the same as for the method-based syntax.