Search code examples
rplotgraphcolorslikert

How to fix color for the Likert data in R package HH?


I would like to assign colors according to my choice;

data

resp <- data.frame(replicate(50, sample(1:7, 100, replace=TRUE)))
resp <- data.frame(lapply(resp, factor, ordered=TRUE, 
                levels=1:7, 
                labels=c("Missing","Not Applicable","Strongly disagree","Disagree", "Neutral","Agree","Strongly Agree")))

resp = t(apply(resp,2,table))[,levels(resp[,1])]

plot likert

I don't want to use diverge_hcl or sequential_hcl.

library(HH)
myColor <- likertColor(nc=7, ReferenceZero=5)

plot.likert(resp,as.percent=TRUE,col=myColor)

Likert Plot for example

I have two columns extra named "Missing" and "Not Applicable". I need a color scheme that relates to the categories, such as:-

  • Missing = "light grey"
  • Not applicable = "Grey"
  • Strongly Disagree = "Red"
  • Disagree = "ligt red"
  • Netural = "White" or "Yellow"
  • Agree = "Light Blue"
  • Strongly Agree = "Blue"

Is there any idea that how to apply above color scheme to my plot?


Solution

  • Simple answer is :

      myColor <- c("light gray","gray","blue","light blue","white","pink","red")
      plot.likert(resp,as.percent=TRUE,col=myColor)