带置信区间的误差条#

这个例子展示了如何使用置信区间显示误差条。 置信区间是通过vega内部的非参数 bootstrap of the mean计算得出的。

import altair as alt
from vega_datasets import data

source = data.barley()

error_bars = alt.Chart(source).mark_errorbar(extent='ci').encode(
  alt.X('yield').scale(zero=False),
  alt.Y('variety')
)

points = alt.Chart(source).mark_point(filled=True, color='black').encode(
  x=alt.X('mean(yield)'),
  y=alt.Y('variety'),
)

error_bars + points
import altair as alt
from vega_datasets import data

source = data.barley()

error_bars = alt.Chart(source).mark_errorbar(extent='ci').encode(
  x=alt.X('yield:Q', scale=alt.Scale(zero=False)),
  y=alt.Y('variety:N')
)

points = alt.Chart(source).mark_point(filled=True, color='black').encode(
  x=alt.X('yield:Q', aggregate='mean'),
  y=alt.Y('variety:N'),
)

error_bars + points