Reversing the direction of an axis currently needs an explicit 'xlim' such that diff(xlim) < 0 [I think]. Thus, the assumption to do a "forward" plot when "leaving out" one element in 'xlim' by setting it to a missing value is not too bad.
However, what about using +Inf and -Inf as instead? Disclaimer: I haven't bumped into one, but it could be that there plot functions that include -Inf/+Inf. Example: ## Case #1: Infer 2nd argument in 'xlim' from data # (a) Forward plot(x, xlim=c(0,+Inf)) # (b) Reverse plot(x, xlim=c(0,-Inf)) ## Case #2: Infer 1st argument in 'xlim' from data # (a) Forward plot(x, xlim=c(-Inf,0)) # (b) Reverse plot(x, xlim=c(+Inf,0)) ## Case #3: Infer both arguments in 'xlim' from data # (a) Forward plot(x, xlim=c(-Inf,+Inf)) # (b) Reverse plot(x, xlim=c(+Inf,-Inf)) Note how the latter also supports a use case currently not supported. /Henrik On Mon, Apr 16, 2012 at 12:15 PM, Duncan Murdoch <murdoch.dun...@gmail.com> wrote: > On 12-04-16 2:26 PM, William Dunlap wrote: >> >> plot(1:10, xlim=c(10,1)) reverses the x axis. >> If we allow plot(1:10, xlim=c(5,NA)), which >> direction should it go? Would this require new >> parameters, {x,y}{min,max} or new paremeters >> {x,y}{axisDirection}? > > > I'd rather not add another parameter. So if I were to implement this, I'd > probably choose Paul's original suggestion. If someone wants c(5, NA) to > mean c(5, min(data)) rather than c(5, max(data)) they'd need to code it > explicitly. > > Duncan Murdoch > > >> >> Bill Dunlap >> Spotfire, TIBCO Software >> wdunlap tibco.com >> >> >>> -----Original Message----- >>> From: r-devel-boun...@r-project.org >>> [mailto:r-devel-boun...@r-project.org] On Behalf >>> Of Duncan Murdoch >>> Sent: Monday, April 16, 2012 11:14 AM >>> To: Paul Johnson >>> Cc: R Devel List >>> Subject: Re: [Rd] I wish xlim=c(0, NA) would work. How about I send you a >>> patch? >>> >>> On 12-04-16 1:52 PM, Paul Johnson wrote: >>>> >>>> I'm looking for an R mentor. I want to propose a change in management >>>> of plot options xlim and ylim. >>> >>> >>> Your suggestion sounds reasonable, but because plot limits are such a >>> commonly used parameter, it would have to be done quite carefully. The >>> questions I'd ask before implementing it are: >>> >>> - Are there other locations besides plot.default where xlim and ylim >>> are specified? I'd like to have them updated consistently. >>> >>> - Are there any conflicting uses of NA for a limit in published >>> packages? >>> >>> - Which package authors would need to be told about this change, so >>> they could make a compatible change? >>> >>> - Where does it need to be documented? >>> >>> Duncan Murdoch >>> >>>> >>>> Did you ever want to change one coordinate in xlim or ylim? It happens >>>> to me all the time. >>>> >>>> x<- rnorm(100, m=5, s=1) >>>> y<- rnorm(100, m=6, s=1) >>>> plot(x,y) >>>> >>>> ## Oh, I want the "y axis" to show above x=0. >>>> >>>> plot(x,y, xlim=c(0, )) >>>> >>>> ##Output: Error in c(0, ) : argument 2 is empty >>>> >>>> plot(x,y, xlim=c(0,NA )) >>>> ## Output: Error in plot.window(...) : need finite 'xlim' values >>>> >>>> >>>> I wish that plot would let me supply just the min (or max) and then >>>> calculate the other value where needed. >>>> It is a little bit tedious for the user to do that for herself. The >>>> user must be knowledgeable enough to know where the maximum (MAX) is >>>> supposed to be, and then supply xlim=c(0, MAX). I can't see any reason >>>> for insisting users have that deeper understanding of how R calculates >>>> ranges for plots. >>>> >>>> Suppose the user is allowed to supply NA to signal R should fill in the >>>> blanks. >>>> >>>> plot(x,y, xlim=c(0, NA)) >>>> >>>> >>>> In plot.default now, I find this code to manage xlim >>>> >>>> xlim<- if (is.null(xlim)) >>>> range(xy$x[is.finite(xy$x)]) >>>> >>>> And I would change it to be something like >>>> ##get default range >>>> nxlim<- range(xy$x[is.finite(xy$x)]) >>>> >>>> ## if xlim is NULL, so same as current >>>> xlim<- if (is.null(xlim)) nxlim >>>> ## Otherwise, replace NAs in xlim with values from nxlim >>>> else xlim[ is.na(xlim) ]<- nxlim[ is.na(xlim) ] >>>> >>>> >>>> Who is the responsible party for plot.default. How about it? >>>> >>>> Think of how much happier users would be! >>>> >>>> pj >>> >>> >>> ______________________________________________ >>> R-devel@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel > > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel