Open a document in a text editor to answer some questions, then proceed with this notebook.
First import the relevant packages
In [ ]:
import pygal
import numpy as np
import pandas as pd
Then let's define useful variables
In [ ]:
# Experimental subjects
Names = ['Paloma','Corey','Emma','Maizy','Jane','Michael','Megan']
# Number of throws
Throws=range(20)
For the data below, each row corresponds to a set of 20 throws by one experimental subject. The numbers correspond to the ring where the sandbag landed. 'NaN' stands for 'not a number' because the data is missing (does somebody have it?). Load the data by running each of the cells
In [ ]:
# No prism glasses and no acoustic cues
Control=np.empty([7,20]);
Control[0,0:]=[3,2,2,2,1,1,3,2,1,1,1,0,1,1,2,0,0,1,2,0];
Control[1,0:]=[1,0,2,1,2,0,1,1,0,2,1,1,3,1,0,1,1,0,1,0];
Control[2,0:]=[3,1,1,0,3,2,2,2,0,1,1,1,3,1,1,3,1,1,1,1];
Control[3,0:]=['NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN'];
Control[4,0:]=['NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN'];
Control[5,0:]=[1,1,2,1,1,1,1,2,1,1,2,1,1,2,1,1,3,1,2,1];
Control[6,0:]=[3,2,2,2,1,2,2,1,2,1,1,3,2,2,1,2,2,2,2,2];
In [ ]:
# Prism glasses and no acoustic cues
Prism=np.empty([7,20]);
Prism[0,0:]=['NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN'];
Prism[1,0:]=[3,2,2,2,1,2,1,2,1,1,2,1,1,1,1,2,2,1,1,1];
Prism[2,0:]=[4,3,2,3,2,4,4,4,4,3,4,2,2,4,2,2,3,2,2,0];
Prism[3,0:]=[2,3,2,2,2,2,1,1,2,2,2,2,1,1,2,2,2,1,1,1];
Prism[4,0:]=['NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN'];
Prism[5,0:]=[2,3,1,2,3,2,2,2,2,1,1,1,1,1,1,2,1,1,2,2];
Prism[6,0:]=[2,4,2,4,1,3,2,3,1,2,1,1,3,2,3,1,3,3,1,3];
In [ ]:
Music=np.empty([7,20]);
Music[0,0:]=[3,2,2,4,1,2,2,2,1,2,1,2,0,3,2,2,0,0,1,3];
Music[1,0:]=[1,2,2,2,1,1,2,2,2,1,2,1,3,0,1,1,2,0,1,1];
Music[2,0:]=[4,4,2,2,1,1,3,3,4,2,2,3,2,0,1,2,1,1,1,2];
Music[3,0:]=[3,1,2,1,2,0,2,2,1,3,1,2,2,1,2,2,2,2,2,1];
Music[4,0:]=[4,4,1,4,4,2,1,2,2,2,3,2,4,2,2,2,1,2,1,1];
Music[5,0:]=[4,3,3,1,1,2,2,1,3,2,1,1,3,2,1,1,3,2,2,1];
Music[6,0:]=['NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN'];
In [ ]:
Blind=np.empty([7,20]);
Blind[0,0:]=[3,3,3,2,3,3,1,3,3,3,3,3,3,3,3,4,3,2,1,2];
Blind[1,0:]=[4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,4,4,4,4,4];
Blind[2,0:]=[3,4,4,4,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4];
Blind[3,0:]=[2,3,2,1,3,2,2,2,1,0,3,3,3,1,2,2,3,4,3,1];
Blind[4,0:]=[1,1,0,1,2,1,2,2,1,1,2,2,1,3,1,1,2,2,2,3];
Blind[5,0:]=[3,2,2,3,1,1,2,2,1,1,3,2,2,1,2,2,2,2,3,3];
Blind[6,0:]=['NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN','NaN'];
Plot the control data first. Here is an example for the controls.
In [ ]:
# Control graph
fig1 = pygal.XY(show_y_guides=False, dots_size=5, stroke_style={'width': 3})
fig1.title = 'Control (no prism, no acoustic cues)'
fig1.x_title = 'Throw number'
fig1.y_title = 'Ring number'
fig1.y_labels=[0,1,2,3,4];
fig1.add(Names[0], list(zip(Throws,Control[0,0:])))
fig1.add(Names[1], list(zip(Throws,Control[1,0:])))
fig1.add(Names[2], list(zip(Throws,Control[2,0:])))
fig1.add(Names[3], list(zip(Throws,Control[3,0:])))
fig1.add(Names[4], list(zip(Throws,Control[4,0:])))
fig1.add(Names[5], list(zip(Throws,Control[5,0:])))
fig1.add(Names[6], list(zip(Throws,Control[6,0:])))
fig1.add('Mean', list(zip(Throws,np.nanmean(Control, axis=0))))
fig1.render_to_file('Control.svg')
Remember to open a new tab on the browser and to load the .svg file pygal just saved
The line 'fig1.add('Mean', list(zip(Throws,np.nanmean(Control, axis=0))))' is calculating the mean (or average) of the 'Control' variable while omitting any NaN from the calculation
Now copy the commands for 'Control data' in a new cell and create new graphs for each of our conditions. Remember to change the name of the svg file (otherwise Control.svg will be overwritten).
In [ ]:
# Prism graph
In [ ]:
# Music + prism graph
In [ ]:
# Blind graph
Question 1: What preliminary conclusions/interpretations of our data can you make for each group (i.e., what does each graph tell you)?
Make a new graph that only contains the averages (or means) for each experimental condition.
In [ ]:
# Average graph
Question 2: Can you make any interpretations by comparing the averages across groups?
Question 3: Is there another way to analyze/graph the data that would give you some other information?
In [ ]: