Jason Rupert
2009-Dec-01 23:16 UTC
[R] Aligning Diagonally Oriented Labels Under Bar Chart
I searched the forms (i.e., R Search)?and come up with the following suggested
link:
?http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create-rotated-axis-labels_003f
I tried to implement what I believe was being implied by that URL and came up
with the below:
barplot(WorldPhones[1,],
??????? ylim=c(0, 50000),
??????? axes=FALSE, ann=FALSE,
??????? col=terrain.colors(length(WorldPhones[1,])),
??????? xaxt = "n",? xlab = "")
text(1:dim(WorldPhones)[1], par("usr")[3] - 0.1, srt = 45, adj = 1,
???? labels = as.character(colnames(WorldPhones)), xpd = TRUE)
box()
Unfortunately the labels are not aligned with the appropriate bars.? I believe I
am missing something small in order to have the text properly aligned underneath
the appropriate bars.??
Are there any suggestions for correcting this mis-alignment??
Thank you again for any additional feedback, links, hints or insights.?
Peter Alspach
2009-Dec-01 23:29 UTC
[R] Aligning Diagonally Oriented Labels Under Bar Chart
Tena koe Jason Is this an example of what you want? temp <- barplot(3:17) text(temp, rep(-0.5, length(3:17)), LETTERS[3:17], srt=45, adj=1) HTH .... Peter Alspach> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Jason Rupert > Sent: Wednesday, 2 December 2009 12:16 p.m. > To: R-help at r-project.org > Subject: [R] Aligning Diagonally Oriented Labels Under Bar Chart > > I searched the forms (i.e., R Search)?and come up with the > following suggested link: > ? > http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-create- > rotated-axis-labels_003f > > I tried to implement what I believe was being implied by that > URL and came up with the below: > > barplot(WorldPhones[1,], > ??????? ylim=c(0, 50000), > ??????? axes=FALSE, ann=FALSE, > ??????? col=terrain.colors(length(WorldPhones[1,])), > ??????? xaxt = "n",? xlab = "") > > text(1:dim(WorldPhones)[1], par("usr")[3] - 0.1, srt = 45, adj = 1, > ???? labels = as.character(colnames(WorldPhones)), xpd = TRUE) > > box() > > > Unfortunately the labels are not aligned with the appropriate > bars.? I believe I am missing something small in order to > have the text properly aligned underneath the appropriate bars.?? > > Are there any suggestions for correcting this mis-alignment?? > > Thank you again for any additional feedback, links, hints or > insights.? > > > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >