-1

I am looking for a simple solution to rotate the x-axis labels by 45 °.

I have already tested several codes but without success. My last attempt was:

par(old.par)
p3 <- barchart(CASS_Data$PASS_Prozent + CASS_Data$FAIL_Prozent ~ CASS_Data$Buchungsperiode, 
               data=CASS_Data, stack="TRUE", col=c("green","red"), position = "fill",
               xlab="", ylab="", main = paste("Test","Prozent"), ylim=c(0,100), xaxt = "n") 
lab <- CASS_Data$Buchungsperiode
text(x = 1:length(lab), labels = lab, srt = 45, adj = c(1,1), xpd = T)
print(p3)

Unfortunately, the x-axis labels are not rotated. Is there another simple solution?

Arun kumar mahesh
  • 2,173
  • 1
  • 14
  • 19

1 Answers1

0

Here's an example since you did not provide a reproducible example..

Base R Method:

x <- barplot(table(mtcars$cyl), xaxt="n")
labs <- paste(names(table(mtcars$cyl)), "cylinders")
text(cex=1, x=x-.25, y=-1.25, labs, xpd=TRUE, srt=45)

Ggplot Method:

theme(axis.text.x = element_text(angle = 90, hjust = 1))
Javier
  • 732
  • 4
  • 15