Skip to content
Tutorials Center
My learning

Topics

Lesson 28 of 31 ยท Projects

Project: Survey Results Report

Turn Likert survey answers into an honest report: tally responses, draw diverging stacked bars, compare groups with uncertainty and keep the page accessible.

Surveys produce one of the most common and most mishandled kinds of chart data: Likert items, questions answered on a scale from "strongly disagree" to "strongly agree". Done well, a survey report shows at a glance where people are happy and where they are not. Done badly, it is a pile of pie charts that nobody can compare.

In this project you build a small survey report: tally the answers, choose the right chart (a diverging stacked bar), compare two groups without over-claiming, and make the page usable with a screen reader. The tallying is done in Python with plain lists, the way you would with pandas; the chart is an SVG stand-in for what Plotly, Bokeh or Altair would draw. Read choosing the right chart first if you want the general rules.

Step 1: understand Likert data

A Likert item has an ordered set of categories: Strongly disagree, Disagree, Neutral, Agree, Strongly agree. That order carries meaning, which has three consequences for your charts:

  • Use a sequential or diverging color palette that follows the order, not unrelated colors. The two ends are opposites and the middle is neutral, so a diverging palette fits.
  • Keep the categories in scale order on the chart, never sorted by size.
  • Be careful with averages. The distance between "Agree" and "Strongly agree" is not necessarily equal to the distance between "Neutral" and "Agree". Many analysts report the share who agree (the "top-two box") alongside, or instead of, the mean.

In our made-up survey, 40 people each answered three statements about a tutorial site:

  • q1: "The documentation is easy to follow"
  • q2: "The examples run without changes"
  • q3: "I can find what I need quickly"

Half of the respondents are new readers and half are returning ones. The program below builds the 120 individual answers from fixed counts, tallies each question, computes percentages and the agree and disagree shares, and prints a small text chart. It also computes the diverging offsets: the left and right edge of every segment when the neutral band is centered on zero.

Python Tally Likert answers and compute diverging offsets

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Look at q3. The five percentages are 15, 25, 20, 25 and 15, so the "agree" and "disagree" sides are exactly equal: 40 percent each, and the mean is exactly 3.0. A report that printed only "mean 3.0" would hide that the answers are split rather than lukewarm. The offsets show how the diverging layout works: the neutral band runs from -10 to +10, centered on zero, "Disagree" extends to its left and "Agree" to its right. In q1 and q2 the agree share is 70 and 77.5 percent, so those bars lean strongly to the right.

Step 2: pick the chart

Compare the options for showing three Likert items:

Chart Verdict
Pie per question Hard to compare across questions; five slices are hard to read
Clustered bars (5 bars per question) Readable but the eye cannot sum "agree"
100 percent stacked bar Good for totals, but segments sit at different starting points
Diverging stacked bar Best: negative and positive sides align on a common zero line, and you can sort questions by net agreement
flowchart LR
    Q["Counts per question"] --> P["Percent of respondents"]
    P --> N["Center the neutral band on 0"]
    N --> S["Sort questions by net agreement"]
    S --> C["Draw segments<br/>diverging palette in scale order"]

A diverging stacked bar is a 100 percent stacked bar whose baseline is moved to the middle of the neutral band.

In real libraries, Plotly builds it with go.Bar traces (one per category, orientation="h") and negative values for the left side. Altair does it with a mark_bar using x="x_start:Q" and x2="x_end:Q" computed by a window transform, and Bokeh with hbar_stack. All three are read-only here; the arithmetic in Python above is what each needs.

Python
import plotly.graph_objects as go

fig = go.Figure()
for label, color, series in traces:      # one trace per scale category
    fig.add_trace(go.Bar(y=questions, x=series, name=label,
                         orientation="h", marker_color=color))
fig.update_layout(barmode="relative")    # negatives stack left, positives right

Step 3: draw the report

The page below is the stand-in chart plus the part most reports forget, a data table with the same numbers. The chart is wrapped in a <figure> with a <figcaption>, and has role="img" and an aria-label; the table is a real <table> with a caption and header cells. A reader using a screen reader gets the table; a sighted reader gets both. The colors are an orange-to-blue diverging palette, safe for the common kinds of color blindness, and each segment shows its percentage as a direct label when it is wide enough.

Diverging stacked bars with an accessible table

The order of the rows is not the order of the questions. They are sorted by net agreement (agree minus disagree, in percentage points): 67.5 for "Examples run unchanged", 55.0 for "Docs are easy to follow", 0.0 for "I find things quickly". The reader sees the strengths first and the weak spot last, and the dashed zero line makes every bar comparable. This one choice, sorting by the number you want people to compare, improves a survey chart more than any color tweak.

Step 4: compare groups without over-claiming

The report also needs to answer "do new readers feel differently from returning readers?" A grouped comparison is easy to draw and easy to misread. With only 20 people per group, a gap of a few tenths of a point on the 1 to 5 scale could easily be chance. The second program computes the mean and agree share per group and a rough 95 percent margin for the difference of means (1.96 times the standard error). If the interval includes zero, the honest statement is "no clear gap".

Python Group comparison with a rough margin of error

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For every question the new readers score higher (by 0.30 to 0.45 points), but each margin is larger than the difference, so the report must not say "new readers are happier". It can say "new readers scored slightly higher; with 20 people per group the gap is within the noise". That sentence is less exciting and far more useful. When you chart group differences, show the uncertainty: error bars in Plotly (error_x), an interval layer in Altair (mark_errorbar), or Whisker in Bokeh. The statistical charts lesson shows how.

Step 5: finish the report page

  • Title as message. "Examples run unchanged is the highest rated statement; finding things is the weakest" says more than "Survey results". See storytelling with charts.
  • State the base. Always print n (here 40 per statement) and how people were chosen.
  • Report the questions verbatim, and the scale labels.
  • Do not hide the middle. A neutral band that is large is a finding.
  • Accessibility checklist. Text alternative, table of the numbers, contrast of the labels against segment colors, no meaning carried by color alone (labels and order do the work), and a sensible reading order. The color and accessibility lesson has the contrast formula.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Why is a diverging stacked bar a good fit for Likert data?

    The scale has two opposite sides and a middle. Centering the neutral band on zero lets you compare agreement across questions.
  2. 2. Question 3 has a mean of exactly 3.0. What does the percentage breakdown add?

    15 + 25 percent disagree and 25 + 15 percent agree. The mean hides that polarization.
  3. 3. Why are the questions sorted by net agreement rather than by their number?

    Sorting by the quantity you want compared turns the chart into a ranking that is easy to read.
  4. 4. Two groups differ by 0.4 points but the margin is 0.8. What should the report say?

    When the interval for the difference includes zero, the data cannot tell the groups apart. Say so and show the uncertainty.
  5. 5. Which addition makes the chart accessible to a screen-reader user?

    A figure with an aria-label and an HTML table gives non-visual readers the same numbers.

Summary

  • Likert items are ordered; keep their order, use a diverging palette, and be careful with means.
  • Tally to counts and percentages first; the agree and disagree shares tell more than the mean alone.
  • A diverging stacked bar centers the neutral band on zero and is the clearest way to compare several items.
  • Sort questions by the number you want compared, and label segments directly.
  • Compare groups with uncertainty; do not claim a difference that falls inside the margin.
  • Ship an accessible page: caption, text alternative, data table, and colors that do not carry meaning alone.

Next: Practice Exercises with Solutions