6

Possible Duplicate:
Rotate X Axis Labels of twoord.plot in R

The following code runs fine. I wish to get the xlabels to be at 45 angle since they are long and i do not want to change there size (i need the whole name).

mp <- barplot(v,names.arg = c("Lung Lavage Fluid","Erythroleukemic Cell Line", "Blood Plasma","T - Cell Cell Line","Liver Whole Cell","B - Lymphocytes", "panc","prostate","Bladder Urine"),cex.names=0.65,col = c(1,2,3,4,5,6,7,8,9), main = val2,density = 50,angle = 45,xlab = "TISSUE",ylab = "EXPRESSION VALUE", ,border = "blue");

palette(c('blue','green','red','pink','brown','coral','deepskyblue','yellow','yellowgreen'));

Community
  • 1
  • 1
Yigael Satanower
  • 199
  • 2
  • 3
  • 4
  • 1
    This is in the R-FAQ and it's already been asked and answered on SO. http://stackoverflow.com/questions/6079526/rotate-x-axis-labels-of-twoord-plot-in-r. I vote to close. – IRTFM May 29 '11 at 12:02

1 Answers1

5

AFAIK, with base graphics, you can only ask for 0/90° orientation of labels on x- or y-axis (see the las parameter in par()). However, with lattice or ggplot2 you can do it.

Here is an example with lattice::barchart():

tt <- table(sample(LETTERS[1:6], 100, rep=T))
library(lattice)
barchart(tt, horiz=F, 
         scales=list(x=list(rot=45, labels=paste("Fancy label", 1:6))))

bar chart

Replace labels with your own labels or if you already have a named table, leave it as is.

Henry
  • 6,704
  • 2
  • 23
  • 39
chl
  • 27,771
  • 5
  • 51
  • 71