strengejacke / sjPlot

sjPlot - Data Visualization for Statistics in Social Science

Home Page:https://strengejacke.github.io/sjPlot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

In `plot_likert` add an option for the `cat.neutral` bars to be ploted on the LEFT instead of right

hbaniecki opened this issue · comments

EDIT2: Is it a bug that reverse.scale=TRUE moves the grey neutral bars from left to right?

I am not sure, which aesthetics to change, but will give it a try.

sjPlot/R/plot_likert.R

Lines 604 to 618 in d8cd8cd

if (!is.null(cat.neutral)) {
mydat.dk <- as.data.frame(
rbind(mydat.dk,
cbind(x = i,
grp = catcount + adding,
frq = -1 + fr[catcount + adding],
ypos = -1 + (fr[catcount + adding] / 2),
ypos2 = -1 + fr[catcount + adding],
offset = -1 * grid.range[1])
))
# cumulative neutral cat
ypos.sum.dk <- c(ypos.sum.dk, -1 + fr[catcount + adding])
}
}

sjPlot/R/plot_likert.R

Lines 697 to 708 in d8cd8cd

if (!is.null(cat.neutral)) {
gp <- gp +
geom_rect(
data = mydat.dk,
aes(
xmin = .data$x - (geom.size / 2),
xmax = .data$x + (geom.size / 2),
ymin = .data$offset,
ymax = .data$frq + (.data$offset + 1),
fill = "neutral")
)
}

EDIT1. Is the default wrong? The documentation says that the default is left side, but the grey bars are plotted on the RIGHT side.