Bars economic

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

In [1]:
import pandas as pd
import holoviews as hv
from holoviews import opts

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, key_dimensions, value_dimensions)

Plot

In [3]:
macro.to.bars(['Year', 'Country'], 'Trade', []).opts(
    opts.Bars(aspect=3, color=hv.Cycle('tab20'), legend_position='right', fig_size=300, legend_cols=2, stacked=True, xrotation=90))
Out[3]:

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