0

I'm trying to fit a plot in R, and I've got some struggles to rotate the xaxis labels, I already tried this command:

labels=lablist, srt=45, pos=1, xpd=TRUE

But it doesn't work as it says it doesn't know labels. Further I don't know how to get the label names in italic.

Has anyone got any suggestions? Thank you :)

  • do you want to use `ggplot2`? it can be done easily with it... – Nate Jul 23 '16 at 11:23
  • 1
    Please make your example reproducible. It will help us and especially you to think about the problem you are having. You can simulate the data or chip off a chunk from your dataset (more [hints here](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)). Note that all these questions have probably been answered before (R has 145000 questions on SO), for example: http://stackoverflow.com/questions/8975797/how-do-you-make-just-the-x-lab-label-italics-and-not-the-y-lab-label-as-well-i – Roman Luštrik Jul 23 '16 at 11:23
  • It's just an easy barplot command – user6628798 Jul 23 '16 at 11:52
  • Please edit the question and paste in the entire line of code. What you have listed will not attract a useful response. – Dave2e Jul 23 '16 at 14:29

1 Answers1

0

From ?par:

'srt' The string rotation in degrees.  See the comment about
     'crt'.  Only supported by 'text'.

(Not what you want.) Continuing with 'las' and 'font':

 'las' numeric in {0,1,2,3}; the style of axis labels.
      0: always parallel to the axis [_default_],
      1: always horizontal,
      2: always perpendicular to the axis,
      3: always vertical.
 'font' An integer which specifies which font to use for text.  If
      possible, device drivers arrange so that 1 corresponds to
      plain text (the default), 2 to bold face, 3 to italic and 4
      to bold italic.

These can give you:

barplot(setNames(100 * 1:3, nm=c("abc","def","ghi")), las=2, font=3)

enter image description here

Or perhaps:

barplot(setNames(100 * 1:3, nm=c("abc","def","ghi")), las=1, font=3)

enter image description here

r2evans
  • 141,215
  • 6
  • 77
  • 149