Informatics Practices
The score of four teams in 5 IPL matches is available to you. Write a program to plot these in a bar chart.
Answer
import matplotlib.pyplot as plt
import numpy as np
Matches = ['Match 1', 'Match 2', 'Match 3', 'Match 4', 'Match 5']
Team_A = [150, 160, 170, 180, 190]
Team_B = [140, 150, 160, 170, 180]
Team_C = [130, 140, 150, 160, 170]
Team_D = [120, 130, 140, 150, 160]
X = np.arange(len(Matches))
plt.bar(Matches, Team_A, width = 0.15)
plt.bar(X + 0.15, Team_B, width = 0.15)
plt.bar(X + 0.30, Team_C, width = 0.15)
plt.bar(X + 0.45, Team_D, width = 0.15)
plt.xlabel('Matches')
plt.ylabel('Scores')
plt.title('IPL Scores')
plt.legend()
plt.show()
Output

Related Questions
Given a data frame df1 as shown below :
1990 2000 2010 a 52 340 890 b 64 480 560 c 78 688 1102 d 94 766 889 Write code to create a line chart from the 1990 and 2000 columns of dataframe df1.
Given a data frame df1 as shown below :
1990 2000 2010 a 52 340 890 b 64 480 560 c 78 688 1102 d 94 766 889 Write code to create a bar chart plotting the three columns of dataframe df1.
The score of a team in 5 IPL matches is available to you. Write a program to create a pie chart from this data, showing the last match's performance as a wedge.
The prices of a stock for 3 months are given. Write a program to show the variations in prices for each month by 3 lines on same line chart. Make sure to add legends and labels. Show grid also.