Diverging Likert chart
Five-point Likert items as diverging stacked bars centred on the neutral answer.

The Python counterpart of gglikert(). Each row is one survey item; the bar is
split into the five answer levels and shifted so that the neutral answer sits
astride zero: disagreement grows to the left, agreement to the right. Items are
sorted by total agreement, and the side columns give the total share who
disagree (left) and agree (right), so rows can be compared without reading segments.
The setting is Melchior, Warin & Oliveira (2026, Data in Brief), a survey on
sharing COVID-19 news and fake news on Facebook. The data are simulated for
illustration and are not the survey's data or results: 600 respondents answer
six statements about how they read and share COVID-19 news. Percentages come from pd.crosstab(normalize="index"); the subtitle reports a
Friedman test (scipy.stats.friedmanchisquare) asking whether the items
receive the same distribution of answers from the same respondents.
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats
# Simulated data, set in the context of Melchior, Warin & Oliveira (2026) [melchior2026survey]
# Simulated survey: 600 Facebook users, 6 items, answers 1-5 driven by a shared latent attitude
rng = np.random.default_rng(42)
items = {"I check the source before sharing": 0.8, "I trust COVID-19 news on Facebook": -0.9,
"I share news without reading it": -1.1, "Friends' posts shape my views": 0.1,
"I can spot fake COVID-19 news": 0.4, "I report false posts I see": -0.4}
mood = rng.normal(0, 0.8, 600)
answers = pd.DataFrame({item: np.digitize(shift + mood + rng.normal(0, 1, 600),
[-1.6, -0.5, 0.5, 1.6]) + 1
for item, shift in items.items()})
levels = ["Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly agree"]
colors = ["#C0392B", "#F1948A", "#D1D1D6", "#7FB3F5", "#0A64D8"]
pct = answers.melt().pipe(lambda d: pd.crosstab(d.variable, d.value, normalize="index") * 100)
pct["agree"], pct["disagree"] = pct[4] + pct[5], pct[1] + pct[2]
pct = pct.sort_values("agree")
# Friedman test: do the six items get the same answers from the same people?
fr = stats.friedmanchisquare(*[answers[c] for c in answers])
fig, ax = plt.subplots(figsize=(9.5, 5))
y = np.arange(len(pct))
left = -(pct[1] + pct[2] + pct[3] / 2) # start so that neutral is centred on 0
for lev, (name, c) in enumerate(zip(levels, colors), start=1):
ax.barh(y, pct[lev], left=left, color=c, height=0.66, label=name, edgecolor="white", lw=0.8)
for yi, (l, w) in enumerate(zip(left, pct[lev])):
if w >= 6:
ax.text(l + w / 2, yi, f"{w:.0f}", ha="center", va="center", fontsize=8.5,
color="white" if lev in (1, 5) else "#1D1D1F")
left = left + pct[lev]
# Totals on both sides
for yi, (d, a) in enumerate(zip(pct["disagree"], pct["agree"])):
ax.text(-93, yi, f"{d:.0f}%", ha="center", va="center", fontsize=10, color="#C0392B", fontweight="semibold")
ax.text(93, yi, f"{a:.0f}%", ha="center", va="center", fontsize=10, color="#0A64D8", fontweight="semibold")
ax.text(-93, len(pct) - 0.35, "Disagree", ha="center", fontsize=9, color="#6E6E73")
ax.text(93, len(pct) - 0.35, "Agree", ha="center", fontsize=9, color="#6E6E73")
ax.axvline(0, color="#3A3A3C", lw=0.8, zorder=0)
ax.spines["left"].set_visible(False)
ax.set_yticks(y, pct.index)
ax.set_xlim(-102, 102)
ax.set_ylim(-0.6, len(pct) - 0.1)
ax.set_xticks(range(-60, 61, 20), [f"{abs(t)}%" for t in range(-60, 61, 20)])
ax.grid(axis="x"); ax.grid(axis="y", visible=False)
ax.legend(ncols=5, loc="upper center", bbox_to_anchor=(0.5, -0.08), fontsize=9,
handlelength=1, columnspacing=1.2)
ax.set_title("Six statements on COVID-19 news, sorted by total agreement", pad=26)
ax.text(0, 1.02, f"n = {len(answers)} respondents (simulated) · Friedman χ²({answers.shape[1] - 1}) = "
f"{fr.statistic:.0f}, p < .001 · bar labels in %", transform=ax.transAxes,
fontsize=9.5, color="#6E6E73")
plt.show()
# Diverging Likert chart: the R equivalent of plot.py
# Simulated data, set in the context of Melchior, Warin & Oliveira (2026) [melchior2026survey]
# R and NumPy draw different random numbers, so the values differ slightly from the Python figure.
library(ggplot2)
set.seed(42)
# Simulated survey: 600 Facebook users, 6 items, answers 1-5 driven by a shared latent attitude
items <- c("I check the source before sharing" = 0.8, "I trust COVID-19 news on Facebook" = -0.9,
"I share news without reading it" = -1.1, "Friends' posts shape my views" = 0.1,
"I can spot fake COVID-19 news" = 0.4, "I report false posts I see" = -0.4)
mood <- rnorm(600, 0, 0.8)
answers <- sapply(items, function(shift)
findInterval(shift + mood + rnorm(600), c(-1.6, -0.5, 0.5, 1.6)) + 1)
levels <- c("Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly agree")
colors <- setNames(c("#C0392B", "#F1948A", "#D1D1D6", "#7FB3F5", "#0A64D8"), levels)
pct <- t(apply(answers, 2, function(a) 100 * prop.table(table(factor(a, levels = 1:5)))))
pct <- pct[order(pct[, 4] + pct[, 5]), ] # sorted by total agreement, highest on top
# Friedman test: do the six items get the same answers from the same people?
fr <- friedman.test(answers)
# One rectangle per item and answer level, shifted so that neutral is centred on 0
start <- -(pct[, 1] + pct[, 2] + pct[, 3] / 2)
right <- start + t(apply(pct, 1, cumsum))
bars <- data.frame(item = rep(seq_len(nrow(pct)), 5), level = factor(rep(levels, each = nrow(pct)), levels),
share = as.vector(pct), xmax = as.vector(right))
bars$xmin <- bars$xmax - bars$share
bars$text <- ifelse(bars$level %in% levels[c(1, 5)], "white", "#1D1D1F")
totals <- data.frame(item = seq_len(nrow(pct)), disagree = pct[, 1] + pct[, 2],
agree = pct[, 4] + pct[, 5])
p <- ggplot(bars) +
geom_vline(xintercept = 0, colour = "#3A3A3C", linewidth = 0.4) +
geom_rect(aes(xmin = xmin, xmax = xmax, ymin = item - 0.33, ymax = item + 0.33, fill = level),
colour = "white", linewidth = 0.4) +
geom_text(data = bars[bars$share >= 6, ],
aes(x = (xmin + xmax) / 2, y = item, label = sprintf("%.0f", share), colour = text),
size = 3) +
scale_colour_identity() +
# Totals on both sides
geom_text(data = totals, aes(x = -93, y = item, label = sprintf("%.0f%%", disagree)),
colour = "#C0392B", fontface = "bold", size = 3.5) +
geom_text(data = totals, aes(x = 93, y = item, label = sprintf("%.0f%%", agree)),
colour = "#0A64D8", fontface = "bold", size = 3.5) +
annotate("text", x = c(-93, 93), y = nrow(pct) + 0.62, label = c("Disagree", "Agree"),
size = 3.1, colour = "#6E6E73") +
scale_fill_manual(NULL, values = colors) +
scale_x_continuous(breaks = seq(-60, 60, 20), labels = function(v) paste0(abs(v), "%"),
limits = c(-102, 102), expand = c(0, 0)) +
scale_y_continuous(breaks = seq_len(nrow(pct)), labels = rownames(pct),
limits = c(0.4, nrow(pct) + 0.9), expand = c(0, 0)) +
labs(title = "Six statements on COVID-19 news, sorted by total agreement",
subtitle = sprintf("n = %d respondents (simulated) · Friedman χ²(%d) = %.0f, %s · bar labels in %%",
nrow(answers), ncol(answers) - 1, fr$statistic,
if (fr$p.value < .001) "p < .001" else sprintf("p = %.3f", fr$p.value)),
x = NULL, y = NULL) +
theme_minimal(base_size = 11) +
theme(plot.title = element_text(face = "bold"),
plot.title.position = "plot",
plot.subtitle = element_text(size = 8.5, colour = "#6E6E73"),
axis.text.y = element_text(colour = "#1D1D1F", size = 10),
panel.grid.minor = element_blank(), panel.grid.major.y = element_blank(),
legend.position = "bottom", legend.key.size = unit(0.8, "lines"),
legend.text = element_text(size = 9))
print(p)
Figures use the optional PyStatlas style: add plt.style.use("pystatlas.mplstyle") to match the look exactly.
Data source
- Simulated data. Simulated data with a fixed random seed, created for this example.
No real respondents, documents or measurements: the numbers only illustrate how the chart and its statistics work. - Melchior, Warin & Oliveira (2026), survey on COVID-19 fake-news sharing. Melchior, C., Warin, T., & Oliveira, M. (2026). Survey data on COVID-19-related fake-news sharing on Facebook. Data in Brief, 65, 112533. https://doi.org/10.1016/j.dib.2026.112533
The example is set in the context of this paper; unless its description says otherwise, the numbers are simulated and are not the paper's data or results.
The examples illustrate statistical methods. Their numbers are simulated unless an entry says otherwise, and their titles describe what each figure shows in these simulated data — not findings of the cited papers, nor the author's position on the substantive question. For results, context and data, rely on the papers cited here.
How to cite
PyStatlas is created and maintained by Thierry Warin. If it helped your work, please cite it.
Warin, T. (2026). Diverging Likert chart. In PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences (Version 1.1.0) [Computer software]. https://warin.ca/pystatlas/proportions-surveys/likert-diverging/
@misc{warin2026statlas,
author = {Warin, Thierry},
title = {PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences},
year = {2026},
version = {1.1.0},
howpublished = {\url{https://warin.ca/pystatlas/}},
note = {Source code: https://github.com/warint/pystatlas}
}More in Proportions & surveys
Stacked proportions by group
100% stacked bars with percentage labels, n per bar, chi-squared test and Cramér's V.
ggstatsplot::ggbarstats()Mosaic plot with Pearson residuals
Tile areas proportional to cell counts, shaded by Pearson residuals from independence.
vcd::mosaic(shade = TRUE)Proportions with confidence intervals
A sorted dot plot of proportions with Wilson 95% confidence intervals.
ggstats::stat_prop() + geom_errorbar()