DATA VISUALIZATION - Part 4
DATA VISUALIZATION - Part 4
PYTHON PANDAS
INFORMATICS PRACTICES
CLASS XII
HISTOGRAMS
It’s a bar chart showing FREQUENCY DISTRIBUTION.
In this case, the data is grouped into ranges, such as "100 to 199 ", " 200 to 300",
etc, and then plotted as bars based on the frequency values. The Range is also
called as the “Bins”.
The width of the bars show the bins and y axis shows the frequency.
It is Similar to a Bar Graph, but with a difference that, in a Histogram each bar is for
a range of data.
The width of the bars corresponds to the class intervals, while the height of each
bar corresponds to the frequency of the class it represents.
CONCEPT OF FREQUENCY DISTRIBUTION :
Let’s consider a test given to students out of 50 marks. Following are
the scores they get.
Test scores As per the scores lets see how many students
20 scored in different range of scores. Like,
30 20-25 3
45
32
26-30 1
34 31-35 2
24 36-40 0
25 41-45 1
48 46-50 4
50 This data is called the frequency distribution table.
50
49
To manually construct a histogram:
1. The first step is to “bin” the range of values, i.e., divide
the entire range of values into a series of intervals. These
bins may or may not be of same interval size.
2. Then count how many values fall into each interval.
NOTE: The bins are usually non-overlapping intervals of a
variable.
So the histogram of the previously mentioned
data looks like:
HOW TO DRAW HISTOGRAMS IN PYTHON???
Considering the above given data for marks, lets write the code to make the
histogram in python pandas.
Example 1:
import matplotlib.pyplot as plt
data=[20,30,45,32,34,24,25,48,50,50,49]
b=[20,26,31,36,41,46]