Notes 58 Creating Histogram
Notes 58 Creating Histogram
Bar chart represents a single value whereas histogram represents range of value.
It is similar to bar graph but it doesn’t show gaps between the bars.
Syntax:
Here,
Example1:
import matplotlib.pyplot as pl
a=[2,3,7,19,6,8,11,14,15,22,33,24,22,8,2,4]
pl.hist(a)
pl.show()
import matplotlib.pyplot as pl
a=[2,3,7,6,8,12,4]
pl.hist(a)
pl.show()
Defining Range using bins:
import matplotlib.pyplot as pl
a=[2,3,7,6,8,12,4]
pl.hist(a,bins=[1,5,10,15])
pl.show()
import matplotlib.pyplot as pl
a=[2,3,7,6,8,12,4]
pl.hist(a,bins=[1,10,20])
pl.show()