[R] Overlapping x - axis lables

Jim Lemon jim at bitwrit.com.au
Fri Nov 27 07:59:34 CET 2009


On 11/27/2009 05:11 PM, Julia Cains wrote:
> Dear R helpers
>
> Suppose I am plotting a simple scatter plot where no of paired observations (x,y) are say 100.
>
>
> month          length
> 1                   10
> 2                   12
> 3                   17
> 4                   21
> 5                   13
> ..........................
> ..........................
> ..........................
>
> 100              16
>
>
>
> when i run the command
>
> plot(month, length)
>
> the required plot is generated. But the problem is that on  the X - axis, month values are also printed and it becomes difficult to read the month values on the graph.
>   
> (Actually I am working on a stacked graph where I am facing this problem.)
>
> So, how to display only few month values (say 1, 5, 10 and so on) without affecting the original graph i.e. the graph should display all the data 100 points but on x - axix only few month values should be displayed in order to improve the readability.
>
>    
Hi Julia,
Try this:

plot(month,length,xaxt="n")
axis(1,at=seq(1,100,by=5),labels=seq(1,100,by=5))

If the labels are still crowded, increase the "by" value.

Jim




More information about the R-help mailing list