[R] direction of axes of plot

Marc Schwartz MSchwartz at MedAnalytics.com
Mon Jun 28 02:08:41 CEST 2004


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




More information about the R-help mailing list