CBSE Class 12 Informatics Practices Question 133 of 147

Plotting with Pyplot — Question 16

Back to all questions
16
Question

Question 12

Navya has started an online business. A list stores the number of orders in last 6 months. Write a program to plot this data on a horizontal bar chart.

Answer
import matplotlib.pyplot as plt
orders = [150, 200, 180, 250, 300, 220]
months = ['January', 'February', 'March', 'April', 'May', 'June']
plt.barh(months, orders)
plt.xlabel('Number of Orders')
plt.ylabel('Month')
plt.title('Number of Orders in Last 6 Months')
plt.show()
Output
Navya has started an online business. A list stores the number of orders in last 6 months. Write a program to plot this data on a horizontal bar chart. Plotting with Pyplot, Informatics Practices Computer Science Sumita Arora Solutions CBSE Class 12