I am creating a Likert plot using the Likert package in R. One variable (used in the repex below) is an ordered factor with only positive responses. The bar is not centered on the y-axis (i.e., top to bottom) but instead appears at the bottom of the plot. I would like to create the plot with the bar centered horizontally on the y-axis.
NB I am referring to centering on the y-axis (i.e., top-bottom), not the x-axis (left-right). I know that the neutral category is centred on the x-axis, with positive values to the right and negative to the left.
The below plot illustrates how the bar is not centrally aligned on the y-axis.
The next plot illustrates how the bar is centrally aligned on the y-axis, when I include 'negative' response levels.
This final plot further illustrates the issue. The blue line indicates the horizontal center line on the y-axis, which the bar sits below, rather than being centered on it. The yellow highlight indicates the corresponding unexpectedly large amount of white space.
# Load likert
library(likert)
# Create a data frame
ben_DF <- data.frame(Farm = factor(c("Small increase in crop farmland",
"Small increase in crop farmland",
"Small increase in crop farmland",
"Large increase in crop farmland",
"Small increase in crop farmland",
"Large increase in crop farmland",
"Small increase in crop farmland",
"Small increase in crop farmland"),
levels = c("Large decrease in crop farmland",
"Small decrease in crop farmland",
"No change in crop farmland",
"Small increase in crop farmland",
"Large increase in crop farmland"),
ordered = TRUE))
# Plot Likert
plot(likert(ben_DF)) +
theme(legend.position = "right",
legend.direction = "vertical")
This could be related to: R likert graph error when grouping and all responses are negative or positive
Following the suggestion by @jay.sf, the 'solution' was to use a different package (specifically gglikert from ggstats). Provided below for completeness.
# Load packages
library(ggstats)
library(labelled)
# Create a data frame
ben_DF <- data.frame(Farm = factor(c("Small increase in crop farmland",
"Small increase in crop farmland",
"Large increase in crop farmland",
"Small increase in crop farmland",
"Large increase in crop farmland",
"Small increase in crop farmland",
"Small increase in crop farmland"),
levels = c("Large decrease in crop farmland",
"Small decrease in crop farmland",
"No change in crop farmland",
"Small increase in crop farmland",
"Large increase in crop farmland"),
ordered = TRUE))
# Plot Likert
ben_DF <- tibble(ben_DF)
colnames(ben_DF) <- "q1"
gglikert(ben_DF, variable_labels = c(q1 = "Farm")) +
theme(legend.position = "right",
legend.direction = "vertical")+
scale_x_continuous(limits = c(-1.1, 1.1), labels = scales::percent_format(accuracy = 1))