In [30]:
%matplotlib inline
import csv
from random import randint, seed
from matplotlib import pyplot as plt

seed(0)

stimulifile = open('stimuli.csv', 'rb') #Open csv file
stimulicsv = csv.reader(stimulifile) #csv file is a csv.reader object

stimuliinitial = [] #stimuli is an empty array

for line in stimulicsv:
    stimuliinitial.append([int(line[0]), int(line[1])]) #append each line in the csv reader object to the stimuli

In [32]:
stimuliinitial


Out[32]:
[[4, 5],
 [4, 6],
 [4, 7],
 [4, 8],
 [4, 9],
 [5, 6],
 [5, 7],
 [5, 8],
 [5, 9],
 [5, 10],
 [6, 7],
 [6, 8],
 [6, 9],
 [6, 10],
 [6, 11],
 [7, 8],
 [7, 9],
 [7, 10],
 [7, 11],
 [7, 12],
 [8, 9],
 [8, 10],
 [8, 11],
 [8, 12],
 [8, 13],
 [9, 10],
 [9, 11],
 [9, 12],
 [9, 13],
 [9, 14],
 [10, 11],
 [10, 12],
 [10, 13],
 [10, 14],
 [10, 15]]

In [41]:
x = [1,2]
width = .35
a = [stimuliinitial[0][0], stimuliinitial[0][1]]
b = [stimuliinitial[1][0], stimuliinitial[1][1]]

print a
print b

p1 = plt.bar(x,a, width, color = "blue")
p2 = plt.bar(x,b, width, bottom = a, color = "red")
plt.xticks(x)


[4, 5]
[4, 6]
Out[41]:
([<matplotlib.axis.XTick at 0xc0418d0>, <matplotlib.axis.XTick at 0xacc3390>],
 <a list of 2 Text xticklabel objects>)