I am trying to plot a pie chart from a .txt file with data-set looks like:
asp: 2.11
glu: 1.11
arg: 0.99
his: 5.11
acid: 11.1
base: 2.11
now,
1) I want to plot a pie chart with first 4 entries, with proper labeling.
2) and then another pie plot using last 2 entries.
I was trying with this following code but I am getting errors. My code is:
from pylab import *
inp = open('c:/users/rox/desktop/xx.txt','r').read().strip().replace(': ',' ').split('\n')
for line in map(str.split,inp):
x = line[0]
z = line[1]
fracs = [x]
labels = [z]
pie(fracs,labels=labels,explode=None,autopct='%1.1f%%,shadow=False)
show()
but this code is generating an error report: Could not convert string to float...
and do I need to use tempfile to plot first 4 entries present in the .txt file.
if I want to plot pie chart using last two line of data set, then could it be done using slicing.
