Build survey-response bars around a declared midpoint while retaining item counts, nonresponse and the ordered response distribution.
Likert diverging stacks: keep the neutral split and response denominator honest
Plot an ordered response, not a signed measurement
A Likert item records an ordered category such as strongly disagree, disagree, neutral, agree or strongly agree. A diverging stacked bar puts the disagreement categories to the left of a center and agreement categories to the right. It makes direction and balance easy to scan across questions. Yet the categories are ordinal: the spacing between adjacent labels is not guaranteed to represent an equal psychological distance. Do not claim a change from one category to another has a precise numeric magnitude merely because the bar uses equal-width units. The chart should preserve the original five counts and their order; a single favorable-minus-unfavorable score can hide a polarized item with many respondents on both ends. Stacked-bar composition explains the part-to-whole encoding, while signed diverging bars serve a different data type.
Declare the center and the neutral convention
For a five-category item, one useful convention splits the neutral share evenly across the center: half extends left and half extends right. It makes negative and positive segment lengths symmetric around a visually centered neutral category. The neutral response itself remains one category and one count; splitting its drawing width must never double its reported count. Other layouts keep the full neutral block on one side or omit it from the diverging calculation. These choices change the visual origin, so use one convention across every compared item and name it in the legend. The contract below returns segment endpoints, not a plotting-library call, so a renderer can draw exact intervals and an accessible table can show unsplit counts. The center position is a presentation rule, not a statistic. Baseline integrity applies as much to opinion charts as to numeric axes.
Separate item response from invitation count
If 83 people receive a questionnaire and only 59 answer an item, a bar normalized to 100 percent of answers describes those 59 respondents. It does not imply 83 people expressed an opinion. Show response count and missing count beside each item, and choose whether the displayed percentages use answered responses or all invited people. A survey can have different eligible populations per item because of branching, so a single global denominator may be wrong. Missing, skipped, not applicable and explicit neutral are distinct states. The worked example accepts an eligible count per item and uses answered responses for the five segments while returning the missing total separately. If groups differ in response propensity, equal-looking bars can be misleading; inspect who answered before interpreting a difference. Grain and denominator and cohort filters make that comparison auditable.
Compare the distribution before sorting the questions
Sorting items by net agreement can help locate extremes but can also hide the questionnaire's intended order. Declare the sort key and preserve a stable question ID, especially if a dashboard allows resorting. For paired waves, compare like-for-like populations and wording; a changed label or response option can move a bar without a real attitude change. Small subgroups deserve visible sample counts and, where appropriate, an uncertainty display rather than a bold ranking. Use a consistent left-to-right palette whose labels are readable without color. The full five-category distribution belongs in the accompanying table, including neutral and missing counts. Avoid stacked bars so narrow that individual slices disappear; a small-multiple table or grouped display can be clearer for close comparisons. Small-sample display, shared scales and text alternatives support that choice.
Worked contract
RESPONSE_ORDER = ("strongly_disagree", "disagree", "neutral",
"agree", "strongly_agree")
def likert_layout(items: list[tuple[str, int, dict[str, int]]]):
seen_items = set()
output = []
for item_id, eligible, counts in items:
if (not item_id or item_id in seen_items or
not isinstance(eligible, int) or eligible <= 0 or
set(counts) != set(RESPONSE_ORDER) or
any(not isinstance(counts[key], int) or counts[key] < 0
for key in RESPONSE_ORDER)):
raise ValueError("items need unique IDs, eligibility and five counts")
seen_items.add(item_id)
answered = sum(counts.values())
if answered == 0 or answered > eligible:
raise ValueError("answered count must be positive and at most eligible")
shares = {key: counts[key] / answered for key in RESPONSE_ORDER}
neutral_half = shares["neutral"] / 2
cursor = -(shares["strongly_disagree"] + shares["disagree"] + neutral_half)
segments = []
for key, width in (("strongly_disagree", shares["strongly_disagree"]),
("disagree", shares["disagree"]),
("neutral_left", neutral_half),
("neutral_right", neutral_half),
("agree", shares["agree"]),
("strongly_agree", shares["strongly_agree"])):
segments.append((key, cursor, cursor + width))
cursor += width
output.append({"item": item_id, "eligible": eligible,
"answered": answered, "missing": eligible - answered,
"counts": counts.copy(), "segments": segments})
return output
survey = [("onboarding-clarity", 83,
{"strongly_disagree": 5, "disagree": 7, "neutral": 11,
"agree": 23, "strongly_agree": 13})]
layout = likert_layout(survey)[0]
assert (layout["answered"], layout["missing"]) == (59, 24)
assert abs(layout["segments"][0][1] + 17.5 / 59) < 1e-12
assert abs(layout["segments"][2][2]) < 1e-12
assert abs(layout["segments"][-1][2] - 41.5 / 59) < 1e-12
assert layout["counts"]["neutral"] == 11Performance and operating cost
For I items and a fixed five-response scale, validating counts and constructing segment endpoints costs O(I) time and O(I) output space. With a configurable K-category scale, the same approach is O(IK) in time and space. The worked item has 59 answers among 83 eligible people, leaving 24 missing. Its 11 neutral answers are displayed as two widths of 5.5 divided by 59, but still reported as 11 respondents. The left edge is negative 17.5 divided by 59 and the right edge positive 41.5 divided by 59; those lengths sum to one answered-response unit. They are drawing coordinates, not a claim that attitudes are numeric distances.
Common Mistakes
- Treating nonresponse as neutral or silently removing missing counts from the report.
- Counting neutral twice after drawing half its width on each side of the center.
- Mixing percent of answered respondents with percent of all eligible people across items.
- Ranking tiny subgroups as if a few answers establish a stable preference order.
Validation drill
Collect 47 survey items with item-specific eligible counts. For each, reconcile all five answers and missing records, produce centered segments with the same neutral convention, and compare the chart with an accessible count table before sorting items by net agreement.
Read next
- Stacked bars: separate composition from volume and preserve denominators
- Diverging bars: put signed differences on one shared zero
- Aggregation grain and denominator: make every plotted mark auditable
- Uncertainty on charts: show denominators and intervals beside estimates
