This website is for version 5. You can find the documentation for version 4 here.

Bar Chart with Labels#

This example shows a basic horizontal bar chart with labels created with Altair.

import altair as alt
from vega_datasets import data


source = data.wheat()

base = alt.Chart(source).encode(
    x='wheat',
    y="year:O",
    text='wheat'
)
base.mark_bar() + base.mark_text(align='left', dx=2)
import altair as alt
from vega_datasets import data


source = data.wheat()

base = alt.Chart(source).encode(
    x='wheat',
    y="year:O",
    text='wheat'
)
base.mark_bar() + base.mark_text(align='left', dx=2)
# No channel encoding options are specified in this chart
# so the code is the same as for the method-based syntax.