Q. Given the following set of data:
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
Answer :-
(a)
import matplotlib.pyplot as plt import numpy as np a = [ 78 ,72, 69 ,81 ,63 ,67 ,65 ,75 ,79 ,74 ,71, 83 ,71 ,79 ,80 ,69 ] plt.hist( a ) plt.xlabel("Ages") plt.show()
Output :-
(b)
import matplotlib.pyplot as plt import numpy as np a = [ 78 ,72, 69 ,81 ,63 ,67 ,65 ,75 ,79 ,74 ,71, 83 ,71 ,79 ,80 ,69 ] plt.hist( a , orientation="horizontal" ) plt.ylabel("Ages") plt.show()
Output :-
(c)
import matplotlib.pyplot as plt import numpy as np a = [ 78 ,72, 69 ,81 ,63 ,67 ,65 ,75 ,79 ,74 ,71, 83 ,71 ,79 ,80 ,69 ] plt.hist( a , histtype="step" ) plt.xlabel("Ages") plt.show()
Output :-
(d)
import matplotlib.pyplot as plt import numpy as np a = [ 78 ,72, 69 ,81 ,63 ,67 ,65 ,75 ,79 ,74 ,71, 83 ,71 ,79 ,80 ,69 ] plt.hist( a , cumulative = True ) plt.xlabel("Ages") plt.show()
Otuput :-
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )