Displaying Diverging Data — Stacked?

Two ways of creating diverging stacked bar charts in R.

Yuexi (Tracy) Chen
VisUMD
2 min readApr 1, 2022

--

Photo by Cassie Matias on Unsplash.

There are at least seven ways of visualizing Likert Scale Data, and a trendy one is the diverging stacked bar chart. Let’s create it in R! All the code is in this GitHub repo.

  1. First, let’s create some dummy data.

The data looks like this:

Method one: “HH” package

You’ll get a figure like this. Not bad for a one-liner!

Method two: ggplot2

The data format required by ggplot2 is different:

  1. It should be long-format instead of wide-format (read more about the data format here)
  2. Some data points need to be negative to ensure the bar is centered at 0. Let’s make “Disagree” and “Strongly disagree” negative.

The dataframe looks like this:

You’ll get a figure like this:

Though more lines of code, ggplot2 offers more customizations, and you can change almost any aspect of this figure, but not with the HH package.

All the code above is in this GitHub repo.

--

--

Yuexi (Tracy) Chen
VisUMD

Computer science PhD student@Univ of Maryland, working on Human-Computer Interaction (HCI)