<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Advanced plotting
This tutorial will go over more advanced plotting functionality. Before reading this, you should take a look at the basic analysis and plotting tutorial.  First, we'll load in some example data. This dataset is an egg comprised of 30 subjects, who each performed 8 study/test blocks of 16 words each.
Step1:  Accuracy
Step2:  By default, the analyze function will perform an analysis on each list separately, so when you plot the result, it will plot a separate bar for each list, averaged over all subjects
Step3:  We can plot the accuracy for each subject by setting plot_type='subject', and we can change the name of the subject grouping variable by setting the subjname kwarg
Step4:  Furthermore, we can add a title using the title kwarg, and change the y axis limits using ylim
Step5:  In addition to bar plots, accuracy can be plotted as a violin or swarm plot by using the plot_style kwarg
Step6:  We can also group the subjects.  This is useful in cases where you might want to compare analysis results across multiple experiments.  To do this we will reanalyze the data, averaging over lists within a subject, and then use the subjgroup kwarg to group the subjects into two sets
Step7:  Oops, what happened there? By default, the plot function looks to the List column of the df to group the data.  To group according to subject group, we must tell the plot function to plot by subjgroup.  This can be achieved by setting plot_type='subject'
Step8:  If you also have a list grouping (such as first 4 lists / second 4 lists), you can plot the interaction by setting plot_type='split'.  This will create a plot with respect to both the subjgroup and listgroup
Step9:  Like above, these plots can also be violin or swarm plots
Step10:  Memory fingerprints
The Memory Fingerprint plotting works exactly the same as the the accuracy plots, with the except that plot_type='split' only works for the accuracy plots, and the default plot_style is a violinplot, instead of a barplot.
Step11:  Other analyses
Like the plots above, spc, pfr and lagcrp plots can all be plotted according to listgroup or subjgroup by setting the plot_type kwarg.
Plot by list grouping
Step12:  Plot by subject grouping
<ASSISTANT_TASK:>
Python Code:
import quail
%matplotlib inline
egg = quail.load_example_data()
Explanation: Advanced plotting
This tutorial will go over more advanced plotting functionality. Before reading this, you should take a look at the basic analysis and plotting tutorial.  First, we'll load in some example data. This dataset is an egg comprised of 30 subjects, who each performed 8 study/test blocks of 16 words each.
End of explanation
accuracy = egg.analyze('accuracy')
accuracy.get_data().head()
Explanation: Accuracy
End of explanation
ax = accuracy.plot()
Explanation: By default, the analyze function will perform an analysis on each list separately, so when you plot the result, it will plot a separate bar for each list, averaged over all subjects:
End of explanation
ax = accuracy.plot(plot_type='subject', subjname='Subject Number')
Explanation: We can plot the accuracy for each subject by setting plot_type='subject', and we can change the name of the subject grouping variable by setting the subjname kwarg:
End of explanation
ax = accuracy.plot(plot_type='subject', subjname='Subject Number',
                title='Accuracy by Subject', ylim=[0,1])
Explanation: Furthermore, we can add a title using the title kwarg, and change the y axis limits using ylim:
End of explanation
ax = accuracy.plot(plot_type='subject', subjname='Subject Number',
                title='Accuracy by Subject', ylim=[0,1], plot_style='violin')
ax = accuracy.plot(plot_type='subject', subjname='Subject Number',
                title='Accuracy by Subject', ylim=[0,1], plot_style='swarm')
Explanation: In addition to bar plots, accuracy can be plotted as a violin or swarm plot by using the plot_style kwarg:
End of explanation
accuracy = egg.analyze('accuracy', listgroup=['average']*8)
accuracy.get_data().head()
ax = accuracy.plot(subjgroup=['Experiment 1']*15+['Experiment 2']*15)
Explanation: We can also group the subjects.  This is useful in cases where you might want to compare analysis results across multiple experiments.  To do this we will reanalyze the data, averaging over lists within a subject, and then use the subjgroup kwarg to group the subjects into two sets:
End of explanation
ax = accuracy.plot(subjgroup=['Experiment 1']*15+['Experiment 2']*15, plot_type='subject')
Explanation: Oops, what happened there? By default, the plot function looks to the List column of the df to group the data.  To group according to subject group, we must tell the plot function to plot by subjgroup.  This can be achieved by setting plot_type='subject':
End of explanation
accuracy = egg.analyze('accuracy', listgroup=['First 4 Lists']*4+['Second 4 Lists']*4)
ax = accuracy.plot(subjgroup=['Experiment 1']*15+['Experiment 2']*15, plot_type='split')
Explanation: If you also have a list grouping (such as first 4 lists / second 4 lists), you can plot the interaction by setting plot_type='split'.  This will create a plot with respect to both the subjgroup and listgroup:
End of explanation
ax = accuracy.plot(subjgroup=['Experiment 1']*15+['Experiment 2']*15, plot_type='split', plot_style='violin')
ax = accuracy.plot(subjgroup=['Experiment 1']*15+['Experiment 2']*15, plot_type='split', plot_style='swarm')
Explanation: Like above, these plots can also be violin or swarm plots:
End of explanation
fingerprint = egg.analyze('fingerprint', listgroup=['First 4 Lists']*4+['Second 4 Lists']*4)
ax = fingerprint.plot(subjgroup=['Experiment 1']*15+['Experiment 2']*15, plot_type='subject')
ax = fingerprint.plot(subjgroup=['Experiment 1']*15+['Experiment 2']*15, plot_type='list')
Explanation: Memory fingerprints
The Memory Fingerprint plotting works exactly the same as the the accuracy plots, with the except that plot_type='split' only works for the accuracy plots, and the default plot_style is a violinplot, instead of a barplot.
End of explanation
listgroup = ['First 4 Lists']*4+['Second 4 Lists']*4
plot_type = 'list'
spc = egg.analyze('spc', listgroup=listgroup)
ax = spc.plot(plot_type=plot_type, ylim=[0, 1])
pfr = egg.analyze('pfr', listgroup=listgroup)
ax = pfr.plot(plot_type=plot_type)
lagcrp = egg.analyze('lagcrp', listgroup=listgroup)
ax = lagcrp.plot(plot_type=plot_type)
Explanation: Other analyses
Like the plots above, spc, pfr and lagcrp plots can all be plotted according to listgroup or subjgroup by setting the plot_type kwarg.
Plot by list grouping
End of explanation
listgroup=['average']*8
subjgroup = ['Experiment 1']*15+['Experiment 2']*15
plot_type = 'subject'
spc = egg.analyze('spc', listgroup=listgroup)
ax = spc.plot(subjgroup=subjgroup, plot_type=plot_type, ylim=[0,1])
pfr = egg.analyze('pfr', listgroup=listgroup)
ax = pfr.plot(subjgroup=subjgroup, plot_type=plot_type)
lagcrp = egg.analyze('lagcrp', listgroup=listgroup)
ax = lagcrp.plot(subjgroup=subjgroup, plot_type=plot_type)
Explanation: Plot by subject grouping
End of explanation
<END_TASK>