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

From: Marc Schwartz (via MN) <mschwartz_at_mn.rr.com>
Date: Fri 01 Jul 2005 - 07:23:06 EST

On Thu, 2005-06-30 at 23:05 +0200, hulubu@gmx.de wrote:
> Hi all,
>
> - how can I do a barplot with rotated axis labels? I've seen the example for
> 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?
>
>
> Best Regards
> Tom

The same concept for rotating axis labels in a regular plot per the FAQ can be used in a barplot, as long as you know that barplot() returns the bar midpoints. So:

```     ## Increase bottom margin to make room for rotated labels
par(mar = c(7, 4, 4, 2) + 0.1)

## Create plot and get bar midpoints in 'mp'
mp <- barplot(1:10)

## Set up x axis with tick marks alone
axis(1, at = mp, labels = FALSE)

## Create some text labels
labels <- paste("Label", 1:10, sep = " ")

## Plot x axis labels at mp
text(mp, par("usr") - 0.5, srt = 45, adj = 1,
labels = labels, xpd = TRUE)

## Plot x axis label at line 4
mtext(1, text = "X Axis Label", line = 4)

```