Skip to content

Commit

Permalink
Merge pull request #1 from hms-dbmi/master
Browse files Browse the repository at this point in the history
Merge
  • Loading branch information
alexvanscoyk committed Aug 5, 2019
2 parents 940622a + 6a22524 commit 9a49fda
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 0 deletions.
Binary file added materials/fds-audiences.pdf
Binary file not shown.
177 changes: 177 additions & 0 deletions notebooks/flu_data_scaffold.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Advanced Altair: Multiple Coordinated Views"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [],
"source": [
"import altair as alt\n",
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>week</th>\n",
" <th>continent</th>\n",
" <th>country</th>\n",
" <th>value</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>1</td>\n",
" <td>Asia</td>\n",
" <td>Afghanistan</td>\n",
" <td>5.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2</td>\n",
" <td>Asia</td>\n",
" <td>Afghanistan</td>\n",
" <td>13.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>3</td>\n",
" <td>Asia</td>\n",
" <td>Afghanistan</td>\n",
" <td>4.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>4</td>\n",
" <td>Asia</td>\n",
" <td>Afghanistan</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>5</td>\n",
" <td>Asia</td>\n",
" <td>Afghanistan</td>\n",
" <td>0.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" week continent country value\n",
"0 1 Asia Afghanistan 5.0\n",
"1 2 Asia Afghanistan 13.0\n",
"2 3 Asia Afghanistan 4.0\n",
"3 4 Asia Afghanistan 0.0\n",
"4 5 Asia Afghanistan 0.0"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"flu = pd.read_csv('flunet2010_11countries.csv', header=[0,1])\n",
"cols = flu.columns.tolist()\n",
"normed = pd.melt(flu, id_vars=[cols[0]], value_vars=cols[1:], var_name=['continent','country'])\n",
"normed = normed.rename(columns={normed.columns[0]: 'week'})\n",
"normed.head()\n",
"\n",
"# setup renderer for Jupyter Notebooks (not needed for Juptyer Lab)\n",
"alt.renderers.enable('notebook')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualization 1\n",
"\n",
"#### Create Linked Plots Showing Flu Cases per Country and Total Flu Cases per Week"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Selections:\n",
"* Click to select individual countries.\n",
"* Hold shift and click to select multiple countries.\n",
"* Brush barchart to narrow top view."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualization 2\n",
"\n",
"#### Create an Overview+Detail Plot Showing Flu Cases per Country"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualization 3\n",
"#### Create Linked Plots Showing Flu Cases per Country per Week and Total Flu Cases per Country\n",
"For this visualization we create two linked plots. One that shows flu cases per country per week and a second on that show the total of all flu cases per country."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 9a49fda

Please sign in to comment.