Q. Write a program to create a pie bar chart for India's total medals.
Medal tally of Commonwealth games
| Country | Gold | Silver | Bronze | Total |
|---|---|---|---|---|
| Australia | 80 | 59 | 59 | 198 |
| England | 45 | 45 | 46 | 136 |
| India | 26 | 20 | 20 | 66 |
| Canada | 15 | 40 | 27 | 82 |
| New Zealand | 15 | 16 | 15 | 46 |
| South Africa | 13 | 11 | 13 | 37 |
| Wales | 10 | 12 | 14 | 36 |
| Scotland | 9 | 13 | 22 | 44 |
| Nigeria | 9 | 9 | 6 | 24 |
| Cyprus | 8 | 1 | 5 | 14 |
Answer :-
import matplotlib.pyplot as plt
total = [198, 136, 66, 82, 46, 37, 36, 44, 24, 14]
countries = ['Australia', 'England', 'India', \
'Canada', 'New Zealand', 'South Africa',\
'Wales', 'Scotland', 'Nigeria', 'Cyprus']
plt.title("Commonwealth Games 2018 Medal Tally")
plt.axis ("equal")
expl = [0, 0, 0.2, 0, 0, 0, 0, 0, 0, 0]
plt.pie(total, labels = countries, explode = expl, autopct = "%5.1f%%")
plt.show()
Output :-
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )