[R] how to plot y-axis on the right of x-axis
Jim Lemon
jim at bitwrit.com.au
Thu Aug 26 13:20:53 CEST 2010
On 08/26/2010 08:11 AM, elaine kuo wrote:
> ...
> One more request, if the label of axis X wants to be drawn from 5 to 1
> (left to right)
> rather than 1 to 5, is it fine to change axis (4, at = NULL) ?
> If so, which value should be input ?
>
Hi Elaine,
There are a couple of ways to do this. One is to use the revaxis
function (plotrix) that reverses the conventional direction of the axes
by silently changing the sign of the values. If you use this, you must
remember to change the sign of the position of your y axes. Another way
is the plot in the normal direction but print the tick labels backwards:
plot(1:5,xaxt="n")
axis(1,1:5,5:1)
Using this method, you have to remember that your labels don't
correspond to the values, so if you wanted a y axis positioned at x=4,
you would have to use:
axis(2,1:5,pos=2)
Jim
More information about the R-help
mailing list