Construct a bar chart for the types of defects found in the auto parts.
Solution: In order to construct a bar chart for the data in this example, we first need to prepare a frequency distribution table. The data in this example are the defect types, namely 1, 2, 3, 4, and 5. The frequency distribution table is shown in Table 2.4.2. Note that the frequency distribution table also includes a column of cumulative frequency.
Now, to construct the bar chart, we label the intervals of equal length on the horizontal line with the category types of defects and then indicate the frequency of observations associated with each defect by a bar of height proportional to the corresponding frequency. Thus, the desired bar graph, as given in Figure 2.4.4, shows that the defects of type 1 occur the most frequently, type 2 occur the second most frequently, and so on.
Table 2.4.2 Frequency distribution table for the data in Example 2.4.4.
Frequency | Relative | Cumulative | ||
Categories | Tally | or count | frequency | frequency |
1 | ///// ///// //// | 14 | 14/50 | 14 |
2 | ///// ///// /// | 13 | 13/50 | 27 |
3 | ///// //// | 9 | 9/50 | 36 |
4 | ///// // | 7 | 7/50 | 43 |
5 | ///// // | 7 | 7/50 | 50 |
Total | 50 | 1.00 |
Figure 2.4.4 Bar graph for the data in Example 2.4.4.
MINITAB
Using MINITAB, the bar chart is constructed by taking the following steps.
1 Enter the category in column C1.
2 Enter frequencies of the categories in C2.
3 From the Menu bar select Graph Bar Chart. This prompts the following dialog box to appear on the screen:
4 Select one of the three options under Bars represent, that is, Counts of unique values, A function of variables, or Values from a table, depending upon whether the data are sample values, functions of sample values such as means of various samples, or categories and their frequencies.
5 Select one of the three possible bar charts that suits your problem. If we are dealing with only one sample from a single population, then select Simple and click OK. This prompts another dialog box, as shown below, to appear on the screen:
6 Enter C2 in the box under Graph Variables.
7 Enter C1 in the box under Categorical values.
8 There are several other options such as Chart Option, scale; click them and use them as needed. Otherwise click OK. The bar chart will appear identical to the one shown in Figure 2.4.4.
USING R
We can use built in ‘barplot()’ function in R to generate bar charts. First, we obtain the frequency table via the ‘table()’ function. The resulting tabulated categories and their frequencies are then inputted into the ‘barplot()’ function as shown in the following R code.
DefectTypes = c(2,1,3,1,2,1,5,4,3,1,2,3,4,3,1,5,2,3,1,2,3,5,4,3, 1,5,1,4,2,3,2,1,2,5,4,2,4,2,5,1,2,1,2,1,5,2,1,3,1,4) #To obtain the frequencies counts = table(DefectTypes) #To obtain the bar chart barplot(counts, xlab=‘Defect type’, ylab=‘Frequency’)
2.4.4 Histograms
Histograms are extremely powerful graphs that are used to describe quantitative data graphically. Since the shape of a histogram is determined by the frequency distribution table of the given set of data, the first step in constructing a histogram is to create a frequency distribution table. This means that a histogram is not uniquely defined until the classes or bins are defined for a given set of data. However, a carefully constructed histogram can be very informative.
For instance, a histogram provides information about the patterns, location/center, and dispersion of the data. This information is not usually apparent from raw data. We may define a histogram as follows:
Definition 2.4.1
A