In [1]:
%matplotlib inline
import pandas as pd
import seaborn as sns
sns.set(style='ticks', context='poster', font_scale=1.5)
In [2]:
data = pd.read_csv('https://raw.githubusercontent.com/sgagnon/Psych45/master/WWW/demos/Psych45-nback_stats_2018.csv')
# filter RT column so just a number (ms and comma not included)
data.avg_rt = data.avg_rt.str.strip(' ms').str.replace(',', '').astype(float)
data.percent_correct = data.percent_correct.astype(float)
data.combined = data.combined.str.replace(',', '').astype(float)
# task_list = ['2-back', '3-back', '4-back', '5-back', '6-back', '7-back', '8-back']
task_list = ['2-back', '3-back', '4-back', '5-back']
task_list_subset = ['2-back', '3-back', '4-back']
In [3]:
data.head()
Out[3]:
In [4]:
data.groupby(['task']).count().when
Out[4]:
In [5]:
data.groupby(['task']).mean().reset_index()
Out[5]:
In [6]:
g = sns.factorplot(x='task', y='percent_correct',
order=task_list,
data=data,
ci=95,
aspect=2.3,
palette=sns.color_palette("Blues_r",
n_colors=len(task_list)))
g.set_xlabels('')
g.set_ylabels('% correct')
g.set_xticklabels(rotation=30)
sns.despine(trim=True)
In [7]:
g = sns.factorplot(x='task', y='percent_correct',
order=task_list_subset,
data=data,
palette=sns.color_palette("Blues_r",
n_colors=len(task_list_subset)),
ci=95,
aspect=1.3)
g.set_ylabels('% correct')
g.set_xlabels('')
g.set_xticklabels(rotation=30)
sns.despine(trim=True)
In [8]:
g = sns.factorplot(x='task', y='avg_rt',
order=task_list,
data=data,
palette=sns.color_palette("Blues_r",
n_colors=len(task_list)),
ci=95,
aspect=2.3)
g.set_ylabels('avg RT (ms)')
g.set_xlabels('')
g.set_xticklabels(rotation=30)
sns.despine(trim=True)
In [9]:
g = sns.factorplot(x='task', y='avg_rt',
order=task_list_subset,
data=data,
palette=sns.color_palette("Blues_r",
n_colors=len(task_list_subset)),
ci=95,
aspect=1.3)
g.set_ylabels('avg RT (ms)')
g.set_xlabels('')
g.set_xticklabels(rotation=30)
sns.despine(trim=True)
In [10]:
g = sns.factorplot(x='task', y='combined',
order=task_list,
data=data,
palette=sns.color_palette("Blues_r",
n_colors=len(task_list)),
ci=95,
aspect=2.3)
g.set_ylabels('combined RT (ms)')
g.set_xlabels('')
g.set_xticklabels(rotation=30)
sns.despine(trim=True)