Bars economic

Most examples work across multiple plotting backends, this example is also available for:

In [1]:
import numpy as np
import pandas as pd
import holoviews as hv
hv.extension('matplotlib')

Declaring data

In [2]:
macro_df = pd.read_csv('http://assets.holoviews.org/macro.csv', '\t')
key_dimensions   = [('year', 'Year'), ('country', 'Country')]
value_dimensions = [('unem', 'Unemployment'), ('capmob', 'Capital Mobility'),
                    ('gdp', 'GDP Growth'), ('trade', 'Trade')]
macro = hv.Table(macro_df, kdims=key_dimensions, vdims=value_dimensions)

Plot

In [3]:
%%opts Bars [category_index=2 stack_index=1 group_index=0 xrotation=90 color_by=['stack']] (color=Cycle('tab20'))
%%opts Bars [legend_position='right' legend_cols=2]
macro.to.bars([ 'Year', 'Country'], 'Trade', [])
Out[3]:

Download this notebook from GitHub (right-click to download).