How to create pie chart?
<p>new to Python and stuck with a pie chart.
Apologies for the complexity but I am at a lost as how to proceed ..
I  have this  dataset in the form of a dictionary (part of it)</p>

<pre><code>{'Deaths5': 94, 'Deaths10': 379, 'Deaths12': 388, 'Deaths8': 138, 'Deaths25': None,
 'IM_Deaths2': None, 'Deaths14': 511, 'Deaths1': 20535, 'Deaths23': 2643, 'Deaths6': 62,
 'IM_Deaths1': 4349, 'Deaths17': 1036, 'Deaths18': 1234, 'Sex': '2', 'Deaths11': 358, 'Deaths22': 1708,
 'Deaths21': 1922, 'IM_Frmat': '08', 'SubDiv': '', 'Deaths15': 600, 'Deaths4': 157, 'Admin1': '',
 'IM_Deaths3': None, 'Deaths19': 1125, 'Deaths24': None, 'Frmat': '01', 'Deaths20': 1602, 'Deaths3': 350,
 'Year': '1964', 'Deaths7': 149, 'Deaths9': 311, 'Deaths26': 33, 'Country': '2150',
 'Deaths16': 932, 'Deaths13': 454, 'Deaths2': 4349, 'IM_Deaths4': None, 'Cause': 'A000', 'List': '07A' .......
</code></pre>

<p>I need to generate a pie chart that shows the latest year - 2013,
and shows the top 8 causes of death code 'Cause' from field 'Deaths1'</p>

<p>So to sum it up:</p>

<p>So for example  the data should be filtered as</p>

<pre><code>Year    CAUSE    Top8
2013     A000    5000
2013     A411    400
2013     A50     200
.....
</code></pre>

<p>and then shown as a pie chart with anything after the top 8 treated as 'other'</p>

<p>I could do this very easily with SQL but with Python...I am not sure.</p>

<p>You can use <a href="http://matplotlib.org/examples/pie_and_polar_charts/pie_demo_features.html" rel="nofollow">Matplotlib</a> for creating Pie charts in Python</p>

<p>Example Pie Chart:-</p>

<pre><code>import matplotlib.pyplot as plt

labels = 'A', 'B', 'C', 'D'
sizes = [40, 20, 20, 20]
colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral']
explode = (0, 0.1, 0, 0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
        autopct='%1.1f%%', shadow=True, startangle=90)
plt.axis('equal')
plt.title('Year 2013')
plt.show()
</code></pre>

python python-3.x dictionary charts pie-chart