2

I would like to customize the x axis tick marks of the output from likert function of HH package in R. MWE from package manual:

library(HH)
data("ProfChal", package = "HH")
likert(Question ~ . , data=ProfChal[EmpRows,], as.percent=TRUE,
     ylab=NULL,
     main="Is your job professionally challenging?",
     positive.order=TRUE) 

Currently, x axis tick marks are in increments of 20 units. I would like to make it to 10 units. Note that I would still like my tick marks to the left of 0 to be positive.

ZygD
  • 22,092
  • 39
  • 79
  • 102

1 Answers1

2

The HH likert function uses the lattice package for plotting (specifically the barchart function) and you can use standard lattice formatting arguments within the likert function. In the code below, I've added xlim and scales arguments to show how to set the axis limits and breaks, respectively.

likert(Question ~ . , data=ProfChal, as.percent=TRUE,
       ylab=NULL,
       main="Is your job professionally challenging?",
       positive.order=TRUE, 
       xlim=c(-50,100),
       scales=list(x=list(at=seq(-50,100,10),
                          labels=c(seq(50,0,-10),seq(10,100,10))))
       ) 

enter image description here

eipi10
  • 91,525
  • 24
  • 209
  • 285