Back to Resources
Data Visualization

Segmented Bar Chart: When to Use It and How to Build One

Saad Selim
May 4, 2026
10 min read

A segmented bar chart (also called a stacked bar chart) divides each bar into colored segments that represent parts of a whole. Each segment shows the contribution of a sub-category to the total, making it easy to compare both the total values and the composition across categories.

Segmented bar charts answer the question: "How does the breakdown change across groups?" They are among the most commonly used chart types in business reporting, dashboards, and presentations because they pack compositional information into a compact visual form.

What a Segmented Bar Chart Shows

Each bar represents a category (like a month, region, or product line). The bar is divided into colored segments, each representing a sub-category. The length of each segment represents its value (or percentage of the total).

Example: Quarterly Revenue by Product Line

Imagine a bar for Q1 2026 divided into:

  • Blue segment (SaaS subscriptions): $2.1M
  • Green segment (Professional services): $800K
  • Orange segment (Hardware): $400K
  • Total bar length: $3.3M

The next bar (Q2) shows the same breakdown, letting you compare how both totals and composition shift over time.

Types of Segmented Bar Charts

Stacked Bar Chart (Absolute Values)

Segments show absolute values. Bar lengths vary based on totals. Use when comparing both total magnitudes and individual component sizes.

Strengths:

  • Shows absolute values and totals simultaneously
  • Easy to compare totals across categories (bar length)
  • Bottom segment is easy to compare precisely (shares a common baseline)

Weaknesses:

  • Middle and top segments are hard to compare precisely (no common baseline)
  • Difficult to see percentage composition when totals differ greatly

100% Stacked Bar Chart (Proportional)

All bars are the same length (100%). Segments show percentages. Use when you care only about composition (relative proportions), not absolute values.

Strengths:

  • Easy to compare proportions across categories
  • Eliminates the effect of different totals
  • Clear for showing share shifts over time

Weaknesses:

  • Hides absolute values (a 50% share could be $1M or $100M)
  • Still difficult to compare middle segments precisely

Grouped (Clustered) Bar Chart

Not technically a segmented chart, but the common alternative. Sub-categories are placed side by side rather than stacked.

Use grouped bars when: You need to compare individual sub-category values precisely across groups. Grouped bars have a common baseline for every segment, making comparison easier.

Use stacked bars when: You want to show part-to-whole relationships and totals.

When to Use a Segmented Bar Chart

Use it when:

  • You have 2-5 sub-categories per bar (more than 5 becomes cluttered)
  • You want to show how parts contribute to a whole
  • Comparing composition across categories is the primary goal
  • Total values and breakdowns both matter

Avoid it when:

  • You have more than 6 sub-categories (too many segments become unreadable)
  • Precise comparison of middle segments is critical (use grouped bars instead)
  • Categories have no logical parts-to-whole relationship
  • A simpler chart (line chart, basic bar chart) would answer the question

How to Build a Segmented Bar Chart

Step 1: Structure Your Data

Your data should have three dimensions:

  • Category (x-axis): time periods, regions, products
  • Sub-category (segment color): the breakdown variable
  • Value (segment length): the metric being measured

Example data structure:

QuarterProduct LineRevenue
Q1SaaS2100000
Q1Services800000
Q1Hardware400000
Q2SaaS2400000
Q2Services750000
Q2Hardware350000

Step 2: Choose Absolute or Percentage

  • If the question is "how much?" or "how do totals compare?": use absolute stacked
  • If the question is "what fraction?" or "how has the mix shifted?": use 100% stacked

Step 3: Order Segments Logically

Recommended approaches:

  • Largest to smallest (most important segment at the bottom, on the common baseline)
  • Consistent order across all bars (never rearrange segments between bars)
  • Logical grouping if categories have a natural hierarchy

Step 4: Choose Colors Carefully

  • Use distinct colors for each segment (avoid similar shades)
  • Maintain color consistency across charts in the same report
  • Consider colorblind accessibility (avoid red-green only schemes)
  • Use muted colors for minor segments, bold colors for key segments

Step 5: Add Context

  • Include a legend (preferably integrated near the chart, not in a separate box)
  • Add data labels for key values if space permits
  • Include totals above or at the end of each bar if absolute comparison matters
  • Title the chart with the insight, not just the data description

Implementation Examples

Python (Matplotlib/Seaborn):

import matplotlib.pyplot as plt
import pandas as pd

df_pivot = df.pivot(index='Quarter', columns='Product', values='Revenue')
df_pivot.plot(kind='bar', stacked=True, figsize=(10, 6))
plt.ylabel('Revenue ($)')
plt.title('Revenue Composition by Quarter')
plt.legend(title='Product Line')
plt.show()

Excel: Select your data range, Insert > Bar Chart > Stacked Bar. Excel automatically stacks the series.

JavaScript (Chart.js, D3, Plotly): Most libraries support stacked bars by setting a "stacked" option to true.

Reading and Interpreting Segmented Bar Charts

What is easy to compare:

  • Total bar lengths (overall comparison across categories)
  • Bottom segment sizes (they share a baseline, enabling precise comparison)
  • Dramatic changes in any segment (obvious visual shifts)

What is hard to compare:

  • Middle segment sizes across bars (different baselines make comparison difficult)
  • Small segments when bars have very different totals
  • Precise values without data labels

Reading strategy:

  1. Compare total bar lengths first (which category is largest overall?)
  2. Look at the bottom segment across bars (how does the largest component change?)
  3. Scan for obvious shifts in proportions (segments growing or shrinking)
  4. If detailed comparison of a specific segment is needed, look for data labels or switch to a grouped bar chart

Common Mistakes

Too many segments. Seven or more colors in a bar chart creates visual noise. Combine small categories into "Other" to keep segments manageable.

Inconsistent segment ordering. If "SaaS" is at the bottom in one chart and in the middle in another, readers lose continuity. Always maintain the same stacking order.

Missing legend or unclear colors. Never assume readers can distinguish between similar shades. Use a clear legend and distinct colors.

Using stacked bars when grouped bars would be clearer. If your audience needs to compare one specific sub-category across groups (e.g., "How did Services revenue change each quarter?"), a grouped bar chart or a simple line chart is better.

Ignoring the "so what." A chart without context is just decoration. Annotate key changes ("SaaS grew from 64% to 72% share") to guide interpretation.

Segmented Bar Charts in Analytics Dashboards

In business intelligence and analytics platforms, segmented bar charts are among the most requested visualizations. When a user asks a question like "show me revenue breakdown by product line over the last year," platforms like Skopx can render a segmented bar chart that immediately shows both the growth trend and the compositional shift.

The chart type works particularly well for:

  • Budget allocation comparisons across departments
  • Marketing channel mix over time
  • Customer segment contribution to total revenue
  • Support ticket distribution by priority and category

Alternatives to Consider

If You Need...Consider
Precise sub-category comparisonGrouped bar chart
Composition of a single categoryPie chart or donut chart
Composition over continuous timeStacked area chart
Part-to-whole with many categoriesTreemap
Comparing two specific time periodsBack-to-back bars or slope chart

Summary

Segmented bar charts show parts of a whole across categories by stacking colored segments within each bar. Use absolute stacking when totals matter and 100% stacking when proportions matter. Keep segments to 5 or fewer, maintain consistent ordering and colors, and add data labels where precision is needed. When comparing individual segments across categories is the primary goal, switch to grouped bars instead. The segmented bar chart excels at revealing compositional shifts and total comparisons in a single compact visualization.

Share this article

Saad Selim

The Skopx engineering and product team

Stay Updated

Get the latest insights on AI-powered code intelligence delivered to your inbox.