Paul Johnson
2012-Apr-16 17:52 UTC
[Rd] I wish xlim=c(0, NA) would work. How about I send you a patch?
I'm looking for an R mentor. I want to propose a change in management of plot options xlim and ylim. 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 -- Paul E. Johnson Professor, Political Science ? ?Assoc. Director 1541 Lilac Lane, Room 504 ? ? Center for Research Methods University of Kansas ? ? ? ? ? ? ? University of Kansas http://pj.freefaculty.org ? ? ? ? ? ?http://quant.ku.edu
Duncan Murdoch
2012-Apr-16 18:13 UTC
[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
David L Lorenz
2012-Apr-16 18:19 UTC
[Rd] I wish xlim=c(0, NA) would work. How about I send you a patch?
Paul, How about plot(x,y, xlim=c(0, max(pretty(x)))) Dave From: Paul Johnson <pauljohn32@gmail.com> To: R Devel List <r-devel@r-project.org> Date: 04/16/2012 12:54 PM Subject: [Rd] I wish xlim=c(0, NA) would work. How about I send you a patch? Sent by: r-devel-bounces@r-project.org I'm looking for an R mentor. I want to propose a change in management of plot options xlim and ylim. 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 -- Paul E. Johnson Professor, Political Science Assoc. Director 1541 Lilac Lane, Room 504 Center for Research Methods University of Kansas University of Kansas http://pj.freefaculty.org http://quant.ku.edu ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel [[alternative HTML version deleted]]
Greg Snow
2012-Apr-16 20:20 UTC
[Rd] I wish xlim=c(0, NA) would work. How about I send you a patch?
The simple work around is to use the range function, if you use something like: xlim=range(0,x) then 0 will be included in the range of the x axis (and if there are values less than 0 then those values will be included as well) and the max is computed from the data as usual. The range function will also accept multiple vectors and make the range big enough to include all of them on the plot (this is what I use when I will be adding additional information using points or lines). With this functionality in range I don't really see much need for the proposed change, maybe an example on the plot help page to show this would suffice. On Mon, Apr 16, 2012 at 11:52 AM, Paul Johnson <pauljohn32 at gmail.com> wrote:> I'm looking for an R mentor. ?I want to propose a change in management > of plot options xlim and ylim. > > 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 > -- > Paul E. Johnson > Professor, Political Science ? ?Assoc. Director > 1541 Lilac Lane, Room 504 ? ? Center for Research Methods > University of Kansas ? ? ? ? ? ? ? University of Kansas > http://pj.freefaculty.org ? ? ? ? ? ?http://quant.ku.edu > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com
Possibly Parallel Threads
- time series line plot: Error in plot.window(...) : invalid 'xlim' value
- wishlist item: changing origin of plot (PR#5045)
- shade overlapping portions of circles (or other shapes)
- "pairs" with same xlim and ylim scale
- non ascill characters in plots. no alternative but plotmath?