[R] direction of axes of plot

Henrik Andersson h.andersson at nioo.knaw.nl
Mon Jun 28 09:43:18 CEST 2004


Assume I want to put this into a function, how do I redefine the margins 
to fit better.

I did par(mar=c(4.1,4.1,5.1,2.1) inside the function, but then it is not 
possible anymore to change them, I just want to change the default for 
this plotting function, how ?

#----------------------------------------------------------
#Function to be improved
#-----------------------------------------------------
plot.revy <- function(x,y,...)
   {
     plot(x,y,ylim=rev(range(y)),axes = FALSE,...)
     axis(2)
     axis(3)
     box()
   }

Ross Ihaka wrote:

> XIAO LIU wrote:
> 
>> R users:
>>
>> I want X-Y plotting with axes in reverse direction such as (0, -1, -2, 
>> -3, ....).  How can I do it?
>>
>> Thanks in advance
> 
> 
> Use the xlim and ylim arguments to plot.
> 
>     x = -(1:10)
>     y = rnorm(10)
> 
>     # Standard plot
>     plot(x, y)
> 
>     # Reversed x-axis
>     plot(x, y, xlim=rev(range(x)))
>




More information about the R-help mailing list