I'm trying to read in a delimited csv called 'StabilityResults.csv' and create a bar plot of column 7 with x-labels from column 0. Getting the labels from column 0 is not a problem but reading the values from col7 into a list doesn't seem to work as a valid input in matplotlib. Is there a way to convert my list of values so they are readable in matplotlib??
import matplotlib.pyplot as plt
import csv
import numpy as np
res = csv.reader(open('StabilityResults.csv'), delimiter=',')
res.next() # do not read header
mut = []
tot = []
a = 0
width = 0.2
for col in res:
mut.append(col[0])
tot.append(col[7])
a += 1
ind = arange(a)
p1 = plt.bar(ind,tot,width,color='r')
labs = plt.xticks(ind+width,mut)
plt.show()
I also reading column7 using numpy's genfromtxt function but this gave an array which also didnt work.
tot2 = np.genfromtxt('StabilityResults.csv', delimiter=',', dtype=None, names=True, deletechars=',', usecols=[7])
genfromtxtit should work. What error message dit you get?