Nikolos Gurney
Nikolos Gurney

Reputation: 45

Rotate Axis Labels in R - HH Package

Any suggestions on rotating the axis labels in a plot from the HH package in R?

In the example below, I would like the labels A, B, and C to be at a 45-degree angle. 'rot' only rotates the ticks, and text(object, srt=45) doesn't seem to work.

library(HH)

test<-data.frame('A'=c(10,12,40,12),
             'B'=c(14,23,13,30),
             'C'=c(11,40,12,16))
rownames(test)<-c("No","Maybe","Plausible","Yes")

likert(t(test)[,1:4], horizontal = FALSE,as.percent = TRUE,
   main = NULL,
   xlab = "Percent", # becomes ylab due to horizontal arg
   ylab = "Condition", #xlab.top = "Total in Condition", 
   ylab.right = FALSE #removes Row Count Totals from Right)

Upvotes: 1

Views: 268

Answers (1)

missuse
missuse

Reputation: 19716

Here is an approach:

likert(t(test)[,1:4], horizontal = FALSE,as.percent = TRUE,
       main = NULL,
       xlab = "Percent", # becomes ylab due to horizontal arg
       ylab = "Condition", #xlab.top = "Total in Condition", 
       ylab.right = FALSE,
       scales = list(x = list(rot = c(45, 0))))

enter image description here

This is the same as with other lattice graphs. A two element vector is provided for the rotation of bottom and upper labels.

Upvotes: 1

Related Questions