如何修复R包HH中的Likert数据的颜色?

时间:2015-08-22 10:58:43

标签: r plot graph colors likert

我想根据我的选择分配颜色;

数据

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

我不想使用diverge_hcl或sequential_hcl。

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

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

Likert Plot for example

我有两个额外的名为&#34; Missing&#34;和&#34;不适用&#34;。 我需要一个与类别相关的配色方案,例如: -

  • 缺少=&#34;浅灰色&#34;
  • 不适用=&#34;格雷&#34;
  • 非常不同意=&#34;红色&#34;
  • 不同意=&#34;红色&#34;
  • Netural =&#34; White&#34;或者&#34;黄色&#34;
  • 同意=&#34;浅蓝&#34;
  • 非常同意=&#34; Blue&#34;

有没有想过如何将上面的配色方案应用到我的情节中?

2 个答案:

答案 0 :(得分:0)

简单的答案是:

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

答案 1 :(得分:0)

还可以在十六进制中使用RGB:

plot.likert(resp,as.percent=TRUE,
            col=c("#E94E1B", "#F7AA4E", "#BEBEBE", "#6193CE", "#00508C"))