40  Diagrammatic Presentation – Bar Charts

Bar charts are a staple of data visualization, used extensively to compare data across different categories. They are simple yet powerful tools for presenting categorical data with rectangular bars, where the length of each bar is proportional to the value it represents.

Bar charts can be classified into three types:

  1. Simple Bar Chart: Displays data with simple bars placed at equal distances apart. Each bar represents a single value for a particular category.

  2. Sub-divided (Stacked) Bar Chart: Shows multiple categories stacked on top of each other within a single bar. Each segment of the bar represents a sub-category of the overall category.

  3. Multiple Bar Chart: Places bars next to each other rather than stacking, with each bar representing a different sub-category within the main category.

40.1 Simple Bar Chart

Structure:

A simple bar chart displays rectangular bars with lengths proportional to the values they represent. The bars are plotted either vertically or horizontally. A vertical bar chart is sometimes called a column chart. Each bar represents a single category, and the height or length of the bar corresponds to the data value.

Purpose:

Comparison: Simple bar charts are primarily used to compare the magnitude of values across different categories, making it easy to see which categories are larger or smaller. Clarity: They provide a clear, straightforward visualization of data, where the focus is on comparing single data points between individual categories.

40.2 Simple Bar Chart using R and Python

In R, the base barplot() function draws a vertical bar chart; in Python, matplotlib.pyplot.bar() does the same.

40.3 Horizontal Bar Chart

A horizontal orientation is often easier to read when category labels are long, or when there are many categories to compare. The bars extend along the x-axis, and category labels sit on the y-axis.

40.4 Horizontal Bar Chart using R and Python

40.5 Sub-divided (Stacked) Bar Chart

Structure:

A stacked bar chart also displays rectangular bars, but each bar is divided into sub-sections that stack on top of each other vertically. Each sub-section represents a different sub-category within the main category.

Purpose:

Part-to-Whole Relationships: Stacked bar charts are used to show how different parts contribute to a whole across different categories. Comparison: While they allow comparison of the total sizes across categories, they are especially useful for comparing the segments within those totals.

40.6 Stacked Bar Chart using R and Python

40.6.1 100% Stacked (Percent) Bar Chart

When the focus is the share of each sub-category within a total rather than absolute counts, convert the stack to percentages so every bar sums to 100. This form is especially useful for comparing composition across categories of very different sizes.

40.7 100% Stacked Bar Chart using R and Python

40.8 Multiple Bar Chart

Structure:

Multiple bar charts, or grouped bar charts, feature separate bars for each sub-category, placed next to each other rather than stacked. These are plotted across the same categories for ease of comparison.

Purpose:

Comparative Analysis: They are ideal for comparing multiple sub-categories across the same main categories. Visibility: Grouped bar charts provide a clear view of differences within categories, making it easier to compare each sub-category side by side without the complication of stacking.

40.9 Multiple Bar Chart using R and Python

Each type of bar chart serves different purposes and provides a clear visual differentiation of data. Depending on your specific needs—whether comparing total quantities, proportions within categories, or relationships between sub-categories—each format offers a tailored approach.


Summary

Concept Description
Foundations
Bar Chart A chart that uses rectangular bars whose lengths are proportional to the values they represent
Categorical Data Bar charts visualise discrete categories rather than continuous distributions
Length Encodes Value The length or height of each bar encodes the magnitude of the value being compared
Vertical vs Horizontal Vertical bars are sometimes called column charts; horizontal bars suit long category labels
Types of Bar Chart
Simple Bar Chart Each bar represents a single value for one category, the simplest and most common form
Stacked (Sub-divided) Bar Chart Bars are split into segments stacked on each other to show parts within a whole
Multiple (Grouped) Bar Chart Bars for sub-categories are placed side by side rather than stacked, easing direct comparison
When to Use Each Type
Comparison Across Categories Primary use case: making it easy to see which categories are larger or smaller
Part-to-Whole Relationships Stacked bars highlight how sub-categories contribute to each total
Side-by-Side Comparison Grouped bars are best when readers must compare each sub-category across categories
R Implementation
R via barplot() Use barplot(values, names.arg, col, main, ylab) for the base R simple bar chart
barplot() beside Argument Use beside = TRUE for grouped bars and beside = FALSE for stacked bars in barplot()
Python Implementation
Python via plt.bar() Use matplotlib.pyplot.bar(categories, values, color) for a basic Python bar chart
Stacking with bottom Argument Stack bars in matplotlib by passing bottom = previous_values to subsequent plt.bar() calls
Grouping with x Offsets Group bars in matplotlib by computing x positions like x minus width over 2 and x plus width over 2