Stacked Bar Chart

< Normalized Stacked Bar Chart | Example Gallery | Colored Text Scatter Plot >

from altair import *

Chart(Data(
    format=DataFormat(
        type='csv',
    ),
    url='http://vega.github.io/vega-lite/data/seattle-weather.csv',
)).mark_bar().encode(
    color=Color('weather:N',
        legend=Legend(
            title='Weather type',
        ),
        scale=Scale(
            domain=['sun', 'fog', 'drizzle', 'rain', 'snow'],
            range=['#e7ba52', '#c7c7c7', '#aec7e8', '#1f77b4', '#9467bd'],
        ),
    ),
    x=X('date:T',
        axis=Axis(
            title='Month of the year',
        ),
        timeUnit='month',
    ),
    y='count(*):Q',
)