[R] x axis labels

Jim Lemon jim at bitwrit.com.au
Sun Dec 2 10:29:33 CET 2012


On 12/02/2012 09:49 AM, apprentice wrote:
> Hi,
>
> I have a problem with plotting my data as a histogram using barplot2. I am
> plotting the x axis using axis(). I want to label only every fifth bar and
> not all of them as they get too busy but I don't know how to do it. I was
> trying to set the labels for the axis using at=seq(min value, max value,
> by=5) but that leads to labels not being under the right bars but just sort
> of spread around.
> Does anyone know how to do it properly?
>
Hi Barbara,
Two ways I can think of. Get the bar positions from the call to barplot2:

barpos<-barplot2(...)

Try barp in the plotrix package. By default the bars or groups are 
spaced at integer values and you get the bar positions returned as well.

Jim




More information about the R-help mailing list