I have created a diverging bar plot using the likert package and would like to change the colours. I know that likert plots are ggplot2 objects and therefore adding e.g. scale_fill_brewer()
does change the colours. However, the colours are applied to the factor levels in alphabetical order rather than the logical order from Strongly disagree to Strongly agree and also changes the order in the legend. The data are ordered factors in the data frame.
Can anyone explain how to change the colours and specify the order in these likert plots? I have also tried scale_fill_manual()
and scale_fill_discrete()
.
library(likert)
library(RColorBrewer)
data("mass")
head(mass)
str(mass)
#FIND OUT THE COLUMN NUMBERS FOR ALL COLUMNS
data.frame(colnames(mass))
p1 = plot(likert(mass[,3:15]))+
scale_fill_brewer(palette = "Blues")
p1