[R] Reversing axis label order

Jim Lemon jim at bitwrit.com.au
Tue May 5 10:52:04 CEST 2009


Steve Murray wrote:
> Dear R Users,
>
> I am executing the following command to produce a line graph:
>
> matplot(aggregate_1986[,1], aggregate_1986[,2:3], type="l", col=2:3)
>
> On the x-axis I have values of Latitude (in column 1) ranging from -60 to +80 (left to right on the x-axis). However, I wish to have these values shown in reverse on the x-axis, going from +80 to -60 (ie. North to South in terms of Latitude). I have tried doing this by altering the command as follows:
>
> matplot(-aggregate_1986[,1], aggregate_1986[,2:3], type="l", col=2:3)
>
> ...but this produces the inverse sign of the latitude values along the axis - ie. it goes from -80 to +60.
>
> How do I reverse the display of the axis labels correctly and of course, maintain the associated data values correctly?
>
>   
Hi Steve,
Have a look at rev.axis in the plotrix package.

Jim




More information about the R-help mailing list