Diverging Stacked Bar Chart in Plot

I can’t think of an easy way to center the neutral category… but you can create diverging stacked bar charts by returning a negative value (e.g., a negative count) from the group reducer. For example:

Plot.plot({
  facet: {
    data: data,
    y: "Question"
  },
  color: {
    legend: true,
    domain: scale,
    scheme: "RdBu"
  },
  marks: [
    Plot.barX(
      data,
      Plot.groupZ(
        {
          x(D) {
            switch (D[0]) {
              case "Strongly Disagree":
              case "Disagree":
                return -D.length;
              case "Agree":
              case "Strongly Agree":
              default:
                return D.length;
            }
          }
        },
        {
          x: "Response",
          fill: "Response",
          order: [
            "Disagree",
            "Strongly Disagree",
            "Neutral",
            "Agree",
            "Strongly Agree"
          ]
        }
      )
    )
  ]
})

Note that the stack order is reversed with the negative values, hence the reordered order option.