pie plot in matplotlib in Python
<p>I am trying to plot a pie chart from a <code>.txt</code> file with data-set looks like:  </p>

<pre><code>asp: 2.11
glu: 1.11
arg: 0.99
his: 5.11
acid: 11.1
base: 2.11
</code></pre>

<p>now,
1) I want to plot a pie chart with first 4 entries, with proper labeling.<br>
2) and then another pie plot using last 2 entries.  </p>

<p>I was trying with this following code but I am getting errors. My code is:  </p>

<pre><code>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()
</code></pre>

<p>but this code is generating an error report: Could not convert string to float...</p>

<p>and do I need to use <code>tempfile</code>  to plot first 4 entries present in the <code>.txt</code> file.</p>

<p>if I want to plot pie chart using last two line of data set, then could it be done using <code>slicing</code>.</p>
