Plot guides › By field

Plot Likert scale survey data

A diverging stacked bar chart is the standard way to show Likert responses: disagreement extends left of a centre line, agreement right, and neutral is split across the middle, so questions can be compared at a glance.

Example plot likert scale survey data made with matplotlib
Rendered from the code below, with example data.

When to use it

Watch out: Don't average Likert codes (1-5) and plot a bar of the mean. It hides polarisation; show the full distribution.

Ask for it in pltchat

Upload your file and type something like:

"diverging stacked bar of the Likert answers per question, centred on neutral"

pltchat writes the loader and the plot for your columns, runs it in your browser and shows you the code.

The matplotlib code

Self-contained with example data; swap in pd.read_csv(...) or pd.read_excel(...) for your own file.

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

levels = ["Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly agree"]
colors = ["#ca0020", "#f4a582", "#d9d9d9", "#92c5de", "#0571b0"]
pct = pd.DataFrame([[5, 10, 20, 45, 20], [15, 25, 25, 25, 10],
                    [2, 8, 15, 40, 35], [30, 30, 20, 15, 5]],
                   columns=levels,
                   index=["The tool is easy to use", "Docs are sufficient",
                          "I would recommend it", "Pricing is fair"])

left = -(pct["Strongly disagree"] + pct["Disagree"] + pct["Neutral"] / 2)
fig, ax = plt.subplots(figsize=(7, 3.6))
for level, color in zip(levels, colors):
    ax.barh(pct.index, pct[level], left=left, color=color, label=level, height=0.6)
    left = left + pct[level]
ax.axvline(0, color="k", lw=0.8)
ax.set_xlim(-70, 90)
ax.set_xlabel("% of respondents")
ax.invert_yaxis()
ax.legend(ncol=5, loc="upper center", bbox_to_anchor=(0.5, -0.18), fontsize=7, frameon=False)
ax.spines[["top", "right", "left"]].set_visible(False)
plt.tight_layout()
plt.show()

Make this with your data

Upload a CSV, Excel, JSON or Parquet file. Your first plot is always free.

Related plots