{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Most examples work across multiple plotting backends, this example is also available for:\n", "\n", "* [Matplotlib - bars_economic](../matplotlib/bars_economic.ipynb)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import holoviews as hv\n", "from holoviews import opts\n", "hv.extension('bokeh','matplotlib')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Declaring data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "macro_df = pd.read_csv('http://assets.holoviews.org/macro.csv', delimiter='\\t')\n", "key_dimensions = [('year', 'Year'), ('country', 'Country')]\n", "value_dimensions = [('unem', 'Unemployment'), ('capmob', 'Capital Mobility'),\n", " ('gdp', 'GDP Growth'), ('trade', 'Trade')]\n", "macro = hv.Table(macro_df, key_dimensions, value_dimensions)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bars = macro.to.bars(['Year', 'Country'], 'Trade', [])\n", "bars.opts(\n", " opts.Bars(color=hv.Cycle('Category20'), show_legend=False, stacked=True, \n", " tools=['hover'], width=600, xrotation=90))" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 4 }