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.

PyPlot

1 Like

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
The score of four teams in 5 IPL matches is available to you. Write a program to plot these in a bar chart. Plotting with Pyplot, Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12

Answered By

1 Like


Related Questions