Re: [R] How to rotate the axisnames in a BARPLOT

From: Francisco J. Zagmutt <>
Date: Fri 01 Jul 2005 - 08:25:53 EST

Try the following. I made this based on the eaxmple from FAQ 7.27

tab=table(rpois(100, 2)) #Creates table to make a barplot par(mar = c(6, 4, 4, 2) + 0.1)#Prepares margin to fit x axis labels pts=barplot(tab, xaxt = "n", xlab = "", col="yellow2")#Barplot of tab without x axis or label.
#Also stores the middle points of the bars

axis(side=1,at=pts, labels=F, tick=T)#Creates x axis with tickmarks exactly at the middle of the bars
nam=paste("Text",names(tab))#Names of each category. To be used on labels

text(pts, par("usr")[3] - 1.5, srt = 45, adj = 1, labels = nam, xpd = TRUE)

#Adds the tickmark labels
# adj = 1 will place the text at the end ot the tick marks
# xpd = TRUE will "clip" text outside the plot region

mtext(1, text = "My Axis Label", line = 4) #Adds x axis label at line 2

Second hit of RSiteSearch("logarithmic axis barplot") takes you to barplot2 {gplots}



>Subject: [R] How to rotate the axisnames in a BARPLOT
>Date: Thu, 30 Jun 2005 23:05:15 +0200 (MEST)
>Hi all,
>- how can I do a barplot with rotated axis labels? I've seen the example
>just a plot in the FAQ, but I'll missing the coordinates to plot my text at
>the right position beneath the bars.
>Is there any (easy?) solution?
>- how can I set the y-axis in a barplot to logarithmic scale?
>Many thanks in advance!
>Best Regards
> Tom
> mailing list
>PLEASE do read the posting guide!
> mailing list PLEASE do read the posting guide! Received on Fri Jul 01 08:32:03 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:08 EST