[R] direction of axes of plot
Spencer Graves
spencer.graves at pdf.com
Mon Jun 28 15:22:12 CEST 2004
If you want code that will work in both S-Plus and R, please use
this solution; Ross Ihaka's solution using xlim=rev(range(x)) uses
fewer commands and may be more elegant but generates errors in S-Plus
(6.2 and, I suspect, earlier releases as well, though I did not test
them just now). Best Wishes, Spencer Graves
Marc Schwartz wrote:
>On Sun, 2004-06-27 at 18:24, 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
>>
>>Xiao
>>
>>
>
>If I am understanding what you want, the following should give you an
>example:
>
># Create x and y with negative values
>x <- -1:-10
>y <- -1:-10
>
># Show regular plot
>plot(x, y)
>
># Now plot using -x and -y
># Do not plot the axes or annotation
>plot(-x, -y, axes = FALSE, ann = FALSE)
>
># Now label both x and y axes with negative
># labels. Use pretty() to get standard tick mark locations
># and use rev() to create tick mark labels in reverse order
>axis(1, at = pretty(-x), labels = rev(pretty(x)))
>axis(2, at = pretty(-y), labels = rev(pretty(y)))
>
>HTH,
>
>Marc Schwartz
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list