I want to plot the bar graph for this data :
(0, 68.41780598958333)
(1, 9.018391927083334)
(2, 0.4236653645833333)
(3, 0.5224609375)
(4, 0.4427083333333333)
(5, 0.6256510416666666)
(6, 1.248046875)
(7, 1.0188802083333333)
(8, 1.1717122395833333)
(9, 1.8673502604166667)
(10, 0.8668619791666666)
(11, 1.7233072916666667)
(12, 0.12353515625)
(13, 0.19661458333333334)
(14, 0.17513020833333334)
(15, 0.0006510416666666666)
(16, 12.1572265625)
The code works perfectly but the problem with the xticks the graph I get is like:
I want to have the x-tick in the center of each corresponding bars and shows all numbers not only even. I tried the the len(k)
but the k
is not in a single row its a column. May be I am doing some mistake seems like solution should be easy but I get stuck.
with open("data_binary.txt") as f:
d=(Counter([Counter(i)['1'] for i in f.readlines()]))
s=sum(d.values())
for k, v in d.items():
pct = float(v * 100.0 / s)
data = (k,pct)
print data
width=0.15
plt.bar(k,pct)
#plt.xticks(k)
pl.ylim(0, 80)
plt.xlabel ("Number of ones")
plt.ylabel ("Number of Signatures(%)")
plt.title("Adder@1")
pl.show()