[Rd] wishlist item: changing origin of plot (PR#5045)

stephen at inf.ed.ac.uk stephen at inf.ed.ac.uk
Wed Nov 12 10:24:28 MET 2003


[This is an edited version of an email that I sent to Paul Murrell.
He was in favour of the idea (although he noted the obstacles that: it
could make par() longer;  somebody has to implement it) and
suggested I submit this as a wishlist item.]

Do you think it would be worth adding options to plot commands to
reverse axes?

Here is a simple example:
 
> x <- 1:12
> plot(x)
  
Whereas if I want the x-axis reversed, I need to know the range of
the x data points:
 
>  plot(x, xlim=c(12,1))
 
So, maybe something like:
 
plot(x, x.rev=TRUE)
 
could be implemented.  X.REV could default to FALSE, and then 
plot.default could have something like:
 
 xlim <- if (is.null(xlim)) {
 	if (x.rev)
 		rev( range(xy$x[is.finite(xy$x)]))
 	else 
 	        range(xy$x[is.finite(xy$x)])
 }
 
So, it would reverse the xlimits only if xlim was not specified.
Likewise, code could be added for ylim.
 
The alternative that Paul suggested was to add an option "origin" to
par(), rather than flags x.rev and y.rev.  Presumably then origin
could take values something like "top-left", "bottom-left",
"top-right", "bottom-right".  (However, this will get longer for
specifying all corners for 3-d plots.)

Stephen Eglen



More information about the R-devel mailing list