[R] x-axis tick mark labels running vertically

Marc Schwartz MSchwartz at MedAnalytics.com
Fri May 7 14:36:31 CEST 2004


On Fri, 2004-05-07 at 07:02, Mohamed Abdolell wrote:
> I'm plotting obesity rates (y-axis) vs Public Health Unit (x-axis) for the 
> province of Ontario and would like to have the Public Health Unit names appear 
> vertically rather than the default, horizontally.
> 
> I'm actually using the 'barplot2' function in the {gregmisc} library ... I 
> haven't been able to find a solution in either the barplot2 options or the 
> general plotting options.
> 
> Any pointers would be appreciated.
> 
> - Mohamed


You need to adjust par("las") to alter the orientation of the of the
axis labels:

barplot2(1:4, names.arg = c("one", "two", "three", "four"), las = 2)

You can also use the axis() function separately:

barplot2(1:4)
axis(1, labels = c("one", "two", "three", "four"), las = 2)

Setting par(las = 2) rotates the axis labels so that they are
perpendicular to the axis.

See ?par for more information.

HTH,

Marc Schwartz




More information about the R-help mailing list