# Class 12 Informatics Practices 065 Ch 3 Plotting with PyPlot Sumita Arora Book Exercise Solution

#### Type C: Practical/Knowledge-Based Questions

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

Ans:

import pandas as pd

import matplotlib.pyplot as plt

orderlist = [25,36,75,45,68,70]

month = [‘Sept’, ‘Oct’, ‘Nov’, ‘Dec’, ‘Jan’, ‘Feb’]

plt.barh(month, orderlist)

plt.title(“Online Order – 6 Months”)

plt.ylabel(“Month”)

plt.xlabel(“Orders in Numbers”)

plt.show()

##### Weight measurements for 16 small orders of French fries (in grams).

78    72    69    81     63     67     65     75

79   74    71     83    71      79     80     69

(a) Create a simple histogram from the above data.

(b) Create a horizontal histogram from the above data.

(c) Create a step type of histogram from the above data.

(d) Create a cumulative histogram from the above data.

Ans:

import pandas as pd

import matplotlib.pyplot as plt

measurement  = [78,72,69,81,63,67,65,75,79,74,71,83,71,79,80,69]

11 #(a) Create a simple histogram from the above data.

plt.hist(measurement)

plt.show()

11 #(b) Create a horizontal histogram from the above data.

plt.hist(measurement, orientation=’horizontal’)

plt.show()

11 #(c) Create a step type of histogram from the above data.

plt.hist(measurement, histtype=’step’)

plt.show()

11 #(d) Create a cumulative histogram from the above data.

plt.hist(measurement, cumulative=True)

plt.show()

Output:-

(a)

(b)

(c)

(d)