Skip to content

Instantly share code, notes, and snippets.

@emily-wasserman
Last active June 23, 2017 23:58
Show Gist options
  • Save emily-wasserman/2bcedbfa3b7a1e6437b6918aefd71859 to your computer and use it in GitHub Desktop.
Save emily-wasserman/2bcedbfa3b7a1e6437b6918aefd71859 to your computer and use it in GitHub Desktop.
Mind in the Eyes Performance Under Cognitive Load

A visualization of how working memory load impacts a Theory of Mind task. Subjects viewed 6 sets of 6 Mind in the Eyes trials, of which 4 sets were "load" sets. In "load" sets, trials were interspersed with letters, and subjects were asked to recall the letters at the end of the set.

Data visualization

Displays average Mind in the Eyes score in load/no load sets for each of 50 participants. Horizontal lines indicate overall mean score for load and no load. Cognitive load did not have any significant effect on Mind in the Eyes performance.

subject_id,mean_load,mean_noload
0,1.0,1.5
1,5.0,4.0
2,2.25,3.5
3,1.75,0.5
4,5.5,5.0
5,5.0,3.0
6,4.75,5.0
7,3.0,4.0
8,5.25,6.0
9,5.75,4.5
10,4.0,4.0
11,3.5,4.5
12,4.75,5.0
13,5.0,5.5
14,3.75,5.0
15,5.25,5.5
16,4.0,5.5
17,1.75,3.0
18,5.5,5.5
19,5.0,4.0
20,5.5,6.0
21,4.75,4.0
22,3.0,5.5
23,4.75,4.0
24,3.75,2.0
25,5.5,5.0
26,5.0,4.5
27,4.75,3.5
28,5.0,3.5
29,3.25,2.5
30,5.0,4.5
31,5.0,5.0
32,4.75,5.0
33,4.75,4.5
34,5.25,4.5
35,5.25,2.5
36,5.75,5.5
37,4.5,4.0
38,3.5,4.0
39,4.0,6.0
40,3.75,2.5
41,4.5,4.0
42,4.25,3.5
43,2.75,4.5
44,2.5,0.5
45,3.75,4.0
46,4.0,5.5
47,4.75,3.5
48,5.75,4.5
49,4.75,6.0
50,3.75,3.5
<html>
<style>
.bar1 {fill: steelblue;}
.bar2 {fill: red;}
text {font-family: sans-serif;}
</style>
<div id="chart_cont">
<script src="http://d3js.org/d3.v4.min.js"></script>
<!-- <script src="http://dimplejs.org/dist/dimple.v2.3.0.min.js"></script> -->
<script type="text/javascript">
var margin = {left: 50, top: 100, bottom: 50};
var width = 800 - margin.left,
height = 600 - margin.top - margin.bottom;
var svg = d3.select("body")
.append("svg")
.attr("width", 800)
.attr("height", 600);
// .append('g') //groups svg into a single element; like div
// .attr('class','chart');
svg.append("text")
.text("Mind in the Eyes Scores Under Cognitive Load")
.attr("y",margin.top/4)
.attr("x",margin.left/2)
.style("font-size","30px");
var legend = svg.append("g")
.attr("class","legend")
.attr("transform","translate("+margin.left+','+margin.top/2+")");
legend.append("rect")
.attr("width",15)
.attr("height",15)
.attr("fill","steelblue")
.attr("opacity",0.5);
legend.append("rect")
.attr("width",15)
.attr("height",15)
.attr("fill","red")
.attr("transform","translate(150,0)")
.attr("opacity",0.5);
legend.append("text")
.text("No load")
.attr("transform","translate(20,13)");
legend.append("text")
.text("Load")
.attr("transform","translate(170,13)")
var x = d3.scaleBand().rangeRound([0, width]).padding(0.1),
y = d3.scaleLinear().rangeRound([height, 0]);
var g = svg.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
d3.csv("./mindeyes_scores.csv",function(data) {
x.domain(data.map(function(d) { return d.subject_id; }));
y.domain([0, 6]);
g.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x));
g.append("g")
.attr("class", "axis axis--y")
.call(d3.axisLeft(y));
svg.append("text")
.attr("text-anchor","middle")
.attr("transform","translate(" + (margin.left/3) + "," + (margin.top + height/2) + ")rotate(-90)")
.text("Mean Score");
svg.append("text")
.attr("text-anchor","middle")
.attr("transform","translate(" + (margin.left + width/2) + "," + (height + margin.top + margin.bottom/1.5) + ")")
.text("Subject ID");
svg.append("line")
.attr("x1",""+margin.left)
.attr("y1",margin.top+(height-y(6-4.3)))
.attr("x2","800")
.attr("y2",margin.top+(height-y(6-4.3)))
.attr("stroke","red");
svg.append("line")
.attr("x1",""+margin.left)
.attr("y1",margin.top+(height-y(6-4.17)))
.attr("x2","800")
.attr("y2",margin.top+(height-y(6-4.17)))
.attr("stroke","steelblue");
var barg = g.selectAll(".bar")
.data(data)
.enter().append("g")
barg.append("rect")
.attr("class", "bar1")
.attr("x", function(d) { return x(d.subject_id); })
.attr("y", function(d) { return y(+d.mean_noload); })
.attr("width", x.bandwidth())
.attr("height", function(d) { return height - y(+d.mean_noload); })
.attr("opacity",0.5);
barg.append("rect")
.attr("class", "bar2")
.attr("x", function(d) { return x(d.subject_id); })
.attr("y", function(d) { return y(+d.mean_load); })
.attr("width", x.bandwidth())
.attr("height", function(d) { return height - y(+d.mean_load); })
.attr("opacity",0.5);
});
</script>
</div>
</html>
subject_id mean_load mean_noload
0 1.0 1.5
1 5.0 4.0
2 2.25 3.5
3 1.75 0.5
4 5.5 5.0
5 5.0 3.0
6 4.75 5.0
7 3.0 4.0
8 5.25 6.0
9 5.75 4.5
10 4.0 4.0
11 3.5 4.5
12 4.75 5.0
13 5.0 5.5
14 3.75 5.0
15 5.25 5.5
16 4.0 5.5
17 1.75 3.0
18 5.5 5.5
19 5.0 4.0
20 5.5 6.0
21 4.75 4.0
22 3.0 5.5
23 4.75 4.0
24 3.75 2.0
25 5.5 5.0
26 5.0 4.5
27 4.75 3.5
28 5.0 3.5
29 3.25 2.5
30 5.0 4.5
31 5.0 5.0
32 4.75 5.0
33 4.75 4.5
34 5.25 4.5
35 5.25 2.5
36 5.75 5.5
37 4.5 4.0
38 3.5 4.0
39 4.0 6.0
40 3.75 2.5
41 4.5 4.0
42 4.25 3.5
43 2.75 4.5
44 2.5 0.5
45 3.75 4.0
46 4.0 5.5
47 4.75 3.5
48 5.75 4.5
49 4.75 6.0
50 3.75 3.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment