[Solved] Write a program to create a horizontal bar chart for india’s medal tally in Olympic 2018

   RSS

2
Topic starter

Write a program to create a horizontal bar chart for india’s medal tally in Olympic 2018

This topic was modified 2 months ago by CodeWithBishal-admin
1 Answer
1
Topic starter

Code:

import matplotlib.pyplot as plt


info = ["Gold", "Silver", "Bronze", "Total"]


India = [26,20,20,66]


plt.ylabel("Medal Type")
plt.xlabel("Medal Count")
x = range(len(info))
plt.yticks(x,info)
plt.title("India's Medal Tally in CommonWealth 2018")
plt.barh(x,India,color=["Gold","Silver","Brown","Black"])
plt.show()

Output:

 

 

 

This post was modified 2 months ago 2 times by CodeWithBishal-admin