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]:
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)
Out[41]: