Skip to content

Rotating the x-axis labels of a barplot

5 messages · Josh B, Sascha Vieweg, Peter Ehlers +2 more

#
On 11-04-16 15:04, Josh B wrote:

            
Try to set the parameter: adj=.5 (see ?par). HTH, *S*
#
On 2011-04-16 09:36, Sascha Vieweg wrote:
That won't work (try it).

Use

   text(1:4-0.5, ....)

Peter Ehlers
#
On Apr 16, 2011, at 11:50 AM, Peter Ehlers wrote:

            
Actually, the key is knowing that barplot() returns the bar midpoints (See the Value section of ?barplot).

Thus:

x <- c(4, 1, 1, 1)

mp <- barplot(x, space = 0)

text(mp, par("usr")[3] - 0.025, srt = 45, adj = 1, 
     labels = c("< 750", "750-1000", "1000-1250", "> 1250"), 
     xpd = TRUE, font = 2)

HTH,

Marc Schwartz
#
On 04/16/2011 11:04 PM, Josh B wrote:
Hi Josh,
Have a look at the "barp" function in the plotrix package, in particular 
the "staxx" and "srt" arguments. Try adding "srt=45" to the last example.

Jim