Search code examples
rplotlabeldiagonal

Vertical x labels out of plot


I have a plot where I have introduced vertical x axis labels via las = 2. Those labels are category words. These words are too long, they protrude out of the picture. What can I do, so that they fit into the picture?

This is the code (the x axis labes are German words):

categories <-c("Traditionsbewusst / Heimatverbunden","Bekanntheit
","Jugendlich / Modern
","Professionell
","Sozial engagiert
","Aufstrebend / Motiviert
","Umwelt / Nachhaltigkeit
","Sympathisch
","Familienfreundlich
","Mitreißend
","Posetives Image
","Teamgeist
","Inovativ
")

Ergebnis<-c(2,1,2,2,2,2,2,2,2,2,3,2,2)

plot(Ergebnis,type = "b",main = "Profil Image",xlab = "",ylab = "Bewertung",axes =FALSE)
axis(1,at=1:13,labels = categories,las=2,cex.axis=0.8)
axis(2)

Solution

  • You can adjust the margins using par(mar(c(bottom, left, top, right))) where bottom, left, top, and right and the corresponding margin sizes in inches. In your case, running par(mar = c(15, 3, 3, 3)) before the plot() command seems to do the trick.