Error Bars

< Scatterplot with Filled Circles | Example Gallery | Horizontal Error Bars >

from altair import *

LayeredChart('https://vega.github.io/vega-lite/data/population.json',
    description='A error bar plot showing mean, min, and max in the US population distribution of age groups in 2000.',
    layers=[Chart().mark_rule().encode(
            x='age:O',
            y=Y('min(people):Q',
                axis=Axis(
                    title='population',
                ),
            ),
            y2='max(people):Q',
        ), Chart().mark_tick().encode(
            size=Size(
                value=5.0,
            ),
            x='age:O',
            y=Y('min(people):Q',
                axis=Axis(
                    title='population',
                ),
            ),
        ), Chart().mark_tick().encode(
            size=Size(
                value=5.0,
            ),
            x='age:O',
            y=Y('max(people):Q',
                axis=Axis(
                    title='population',
                ),
            ),
        ), Chart().mark_point().encode(
            size=Size(
                value=2.0,
            ),
            x='age:O',
            y=Y('mean(people):Q',
                axis=Axis(
                    title='population',
                ),
            ),
        )],
    transform=Transform(
        filter='datum.year == 2000',
    ),
)