[R] R ggplot2 legend text left justify

Paul Sutcliffe psutclif at it.uts.edu.au
Tue Feb 9 00:56:46 CET 2010



In ggplot2 how do you justify the legend text ?
In the example below the opts(legend.text = theme_text(size = 
9,hjust=0))  changes the size of the text OK but it remains right 
justified.


 > mydata=data.frame(RowID=c("A","B","C"),Name=c("long long long long 
long name","short name ","medium medium name"),Speed=c(100,140,120))
 > mydata
  RowID                          Name Speed
1     A long long long long long name   100
2     B                   short name    140
3     C            medium medium name   120
 > ggplot(mydata, aes(RowID,Speed))+ opts(legend.text = theme_text(size 
= 9,hjust=0)) + geom_bar() + xlab("Name") + aes(colour = Name) 
+aes(fill=Name)
 >

Thank in advance
Paul


-- 
Dr. Paul J Sutcliffe


Casual Academic
Faculty of Engineering and IT, 
University of Technology, Sydney (UTS) 
email: psutclif at it.uts.edu.au
http://www-staff.it.uts.edu.au/~psutclif/
CRICOS Provider Code 00099F



More information about the R-help mailing list