Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i get a 45 angle for the x axis labels in the following code [duplicate]

Tags:

r

axis-labels

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'));

like image 652
Yigael Satanower Avatar asked May 29 '11 11:05

Yigael Satanower


1 Answers

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.

like image 156
chl Avatar answered Oct 01 '22 20:10

chl