#!/usr/bin/env python # coding: utf-8 # # Area Plots # In[2]: from altair import * # In[3]: data = load_dataset('unemployment-across-industries') data['date'] = data['date'].astype(str) # ## Simple Area Chart # In[4]: Layer(data).mark_area().encode( X('date:T', axis=Axis(format='%Y', labelAngle=0)), y='sum(count)' ) # ## Stacked Area Chart # In[5]: Layer(data).mark_area().encode( X('date:T', timeUnit='yearmonth', axis=Axis(format='%Y', labelAngle=0, title='year')), Y('sum(count)'), Color('series:N', scale=Scale(range="category20b")) ) # ## Normalized Area Chart # In[6]: Layer(data).mark_area(stacked='normalize').encode( X('date:T', timeUnit='yearmonth', axis=Axis(format='%Y', labelAngle=0, title='year')), Y('sum(count)'), color=Color('series:N', scale=Scale(range="category20b")) ) # ## SteamGraph # In[7]: Layer(data).mark_area(stacked='center').encode( X('date:T', timeUnit='yearmonth', axis=Axis(format='%Y', labelAngle=0, title='year')), Y('sum(count)'), color=Color('series:N', scale=Scale(range="category20b")) )