%matplotlib inline
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pylab as plt
sns.set_context('notebook')
/home/fonnesbeck/anaconda3/envs/dev/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds)
severity_data = pd.read_excel('results/severity.xlsx', index_col=0)
settings = {1:'Inpatient', 2:'ED', 3:'Outpatient'}
severity_data['setting_name'] = severity_data.settingnew.map(settings)
severity_data['age_group'] = (pd.cut(severity_data.ageyears, [0, 1, 2, 5, 18], right=False)
.cat.rename_categories(['<1', '1', '2-4', '5+']))
severity_data['virus_count_group'] = severity_data.virus_count.replace({0: 'None', 1: 'One',
2: 'Multiple', 3: 'Multiple',
4: 'Multiple'})
def plot_mvs(x, data=severity_data, cmap='dark', xlabel=''):
sns.stripplot(x=x, y='mvs', palette=cmap,
data=data,
dodge=True, jitter=True, alpha=0.1, zorder=1)
ax = sns.pointplot(x=x, y='mvs',
data=data, cmap=cmap,
dodge=0.532, join=False, color='black',
markers='o', scale=1, ci=False)
sns.despine(offset=10, trim=True);
ax.set_ylabel('MVS')
ax.set_xlabel(xlabel)
return ax
plot_mvs('setting_name', cmap='Set2')
/home/fonnesbeck/anaconda3/envs/dev/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
<matplotlib.axes._subplots.AxesSubplot at 0x7d3eeba0eda0>
plot_mvs('virus_count_group', cmap='Set2', xlabel='Viral detections')
/home/fonnesbeck/anaconda3/envs/dev/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
<matplotlib.axes._subplots.AxesSubplot at 0x7d3eeb613048>
plot_mvs('age_group', cmap='Set2', xlabel='Age (years)')
/home/fonnesbeck/anaconda3/envs/dev/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
<matplotlib.axes._subplots.AxesSubplot at 0x7d3eeb79d470>
ax = plot_mvs('rotavirus', cmap='Set2', xlabel='Rotavirus')
ax.set_xticklabels(['Negative', 'Positive'])
/home/fonnesbeck/anaconda3/envs/dev/lib/python3.6/site-packages/scipy/stats/stats.py:1713: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result. return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumval
[Text(0,0,'Negative'), Text(0,0,'Positive')]