Analysing a single ordinal variable
1b: Visualising the data (compound bar-chart)
In the previous part we got a decent impression of the data for this variable from the previous part, let’s make a visualization out of it. To visualise the data of an ordinal variable, we could use the same diagram as discussed for the single nominal variable (see here): a bar chart. However, since the categories of an ordinal variable have an order, it might be better to place the bars on top of each other, instead of next to each other. This is called a compound bar chart, or sometimes stacked bar chart (Wilkinson, 2005, p. 157) or component bar chart (Zedeck, 2014, p. 54). It can be defined as: “a bar chart showing multiple bars stacked at each x-axis category, each representing a value of the stacking variable” (Upton & Cook, 2014, p. 88). An example is shown in Figure 1.
Figure 1.
Example of a compound bar-chart of a single ordinal variable
Click here to see how to create a stacked bar-chart
with Excel
Excel file from video: VI - Bar Chart (Stacked - Single).xlsm.
with Python
Jupyter Notebook used in video: VI - Bar Chart - Stacked Single Variable.ipynb.
Data file used in video and notebook GSS2012a.csv.
with R
R script used in video: VI - Bar Chart (Single Stack).R.
Data file used in video and notebook GSS2012a.csv.
with SPSS
Datafile used in video: GSS2012-Adjusted.sav
From the figure we can immediately see that only about 30% find accounting pretty or very scientific, while the others do not.
An alternative for the compound bar-chart might be a dual axis bar-chart showing both the count and the cumulative percentage. Although this would provide more information it is a bit harder to read for most people. What this looks like and how to create one is shown in the appendix at the bottom of this page.
With the frequency table and the visualisation we get a decent impression of the data, but besides this some statistical measures to describe the data might also be useful. This is the topic of the next section.
Appendix: Dual axis-bar-chart (click to expand)
A dual axis bar-chart shows both the count and cumulative percentage. An example of such a bar-chart is shown in Figure 2.
Figure 2.
Example of a dual-axis bar-chart
Click here see how to create this dual-axis bar-chart.
with Excel
Excel file from video: VI - Bar Chart (Dual Axis).xlsm.
with Python
Jupyter Notebook used in video: VI - Bar Chart - Dual Axis.ipynb.
Data file used in video and notebook GSS2012a.csv.
with R
without libraries
R script used in video: VI - Bar Chart (Dual Axis).R.
Data file used in video and notebook GSS2012a.csv.
with ggplot library
R script used in video: VI - Bar Chart (Dual Axis).R.
Data file used in video and notebook GSS2012a.csv.
with SPSS
Datafile used in video: GSS2012-Adjusted.sav
Single ordinal variable
Google adds