Hi, I would like to bound the lower limit of my y scale to zero, and let R chose an upper limit. Something like plot(x,ylim=c(0,)) or plot(x,ylim=c(0,na)) but nither of these do the job. I searched the docs, but I can't see a way to do this. Naturally its nothing I can't do 'by hand', I would just like to know if a correct syntax exists.
plot.default and open ended limits
8 messages · Uwe Ligges, Romain Francois, Dan Bolser +1 more
Dan Bolser wrote:
Hi, I would like to bound the lower limit of my y scale to zero, and let R chose an upper limit. Something like plot(x,ylim=c(0,)) or plot(x,ylim=c(0,na)) but nither of these do the job. I searched the docs, but I can't see a way to do this. Naturally its nothing I can't do 'by hand', I would just like to know if a correct syntax exists.
No, but plot(x, ylim = c(0, max(x))) should do the trick. Uwe Ligges
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Hello Dan, Look at the code of the plot.default function, you'll see that's not possible to specify one limit, nevertheless, you can do : plot(x,y,ylim=c(0,max(y))) Does it work for you ? Cordialement. Romain. Dan Bolser a ?crit :
Hi, I would like to bound the lower limit of my y scale to zero, and let R chose an upper limit. Something like plot(x,ylim=c(0,)) or plot(x,ylim=c(0,na)) but nither of these do the job. I searched the docs, but I can't see a way to do this. Naturally its nothing I can't do 'by hand', I would just like to know if a correct syntax exists.
Romain FRANCOIS : francoisromain at free.fr page web : http://addictedtor.free.fr/ (en construction) 06 18 39 14 69 / 01 46 80 65 60 _______________________________________________________ Etudiant en 3eme ann?e Institut de Statistique de l'Universit? de Paris (ISUP) Fili?re Industrie et Services http://www.isup.cicrp.jussieu.fr/
On Sun, 9 Jan 2005, [ISO-8859-1] Romain François wrote:
Hello Dan, Look at the code of the plot.default function, you'll see that's not possible to specify one limit, nevertheless, you can do :
Suppose I wanted to contribute a 'fix' to the code to allow one of my suggested syntax solutions below, how would I go about it? Cheers,
plot(x,y,ylim=c(0,max(y))) Does it work for you ? Cordialement. Romain. Dan Bolser a écrit :
Hi, I would like to bound the lower limit of my y scale to zero, and let R chose an upper limit. Something like plot(x,ylim=c(0,)) or plot(x,ylim=c(0,na)) but nither of these do the job. I searched the docs, but I can't see a way to do this. Naturally its nothing I can't do 'by hand', I would just like to know if a correct syntax exists.
Dan Bolser a ?crit :
Hello Dan, Look at the code of the plot.default function, you'll see that's not possible to specify one limit, nevertheless, you can do :
Suppose I wanted to contribute a 'fix' to the code to allow one of my suggested syntax solutions below, how would I go about it? Cheers,
I suppose you can overwrite the plot.default function and replace that
part :
ylim <- if (is.null(ylim)) range(xy$y[is.finite(xy$y)])
else ylim
by, (( for example )) that :
ylim <- if (is.null(ylim)) range(xy$y[is.finite(xy$y)])
else ylim
if(is.na(ylim[1])) ylim[1] <- min(xy$y[is.finite(xy$y)])
if(is.na(ylim[2])) ylim[2] <- max(xy$y[is.finite(xy$y)])
I haven't tested it but I think that would do the trick if you specify
the ylim argument that way :
plot(x,ylim=c(0,NA)) # note that the NA is in upper case
but I don't know if it's really usefull since ou can use that syntax
below with no problem
plot(x, ylim = c(0, max(x)))
Romain.
plot(x,y,ylim=c(0,max(y))) Does it work for you ? Cordialement. Romain. Dan Bolser a ?crit :
Hi, I would like to bound the lower limit of my y scale to zero, and let R
chose an upper limit.
Something like
plot(x,ylim=c(0,))
or
plot(x,ylim=c(0,na))
but nither of these do the job. I searched the docs, but I can't see a way
to do this.
Naturally its nothing I can't do 'by hand', I would just like to know if a
correct syntax exists.
Romain FRANCOIS : francoisromain at free.fr page web : http://addictedtor.free.fr/ (en construction) 06 18 39 14 69 / 01 46 80 65 60 _______________________________________________________ Etudiant en 3eme ann?e Institut de Statistique de l'Universit? de Paris (ISUP) Fili?re Industrie et Services http://www.isup.cicrp.jussieu.fr/
On Sun, 9 Jan 2005, Dan Bolser wrote:
On Sun, 9 Jan 2005, [ISO-8859-1] Romain François wrote:
Hello Dan, Look at the code of the plot.default function, you'll see that's not possible to specify one limit, nevertheless, you can do :
Suppose I wanted to contribute a 'fix' to the code to allow one of my suggested syntax solutions below, how would I go about it?
The preferred way is to send a patch against the current (R-devel) sources, but if you are modifying a short function it's probably ok to send just the modified version (being careful not to change indenting and spacing in lines you don't modify). However, while we never want to discourage people from contributing fixes, I will note that users will expect ylim=c(0,NA) to work for all plot() methods that accept ylim, if it works for plot.default. Some of these pass their xlim and ylim to plot.default, so it will happen automatically, but some probably don't. -thomas
Cheers,
plot(x,y,ylim=c(0,max(y))) Does it work for you ? Cordialement. Romain. Dan Bolser a écrit :
Hi, I would like to bound the lower limit of my y scale to zero, and let R chose an upper limit. Something like plot(x,ylim=c(0,)) or plot(x,ylim=c(0,na)) but nither of these do the job. I searched the docs, but I can't see a way to do this. Naturally its nothing I can't do 'by hand', I would just like to know if a correct syntax exists.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
On Sun, 9 Jan 2005, Thomas Lumley wrote:
On Sun, 9 Jan 2005, Dan Bolser wrote:
On Sun, 9 Jan 2005, [ISO-8859-1] Romain François wrote:
Hello Dan, Look at the code of the plot.default function, you'll see that's not possible to specify one limit, nevertheless, you can do :
Suppose I wanted to contribute a 'fix' to the code to allow one of my suggested syntax solutions below, how would I go about it?
The preferred way is to send a patch against the current (R-devel) sources, but if you are modifying a short function it's probably ok to send just the modified version (being careful not to change indenting and spacing in lines you don't modify). However, while we never want to discourage people from contributing fixes, I will note that users will expect ylim=c(0,NA) to work for all plot() methods that accept ylim, if it works for plot.default. Some of these pass their xlim and ylim to plot.default, so it will happen automatically, but some probably don't.
Thats a good point. help.search("xlim") / ?xlim don't turn up any pages,
and only plot.default seems to document [xy]lim. Aside from greping the
source / docs how can I find out which plot functions use / abuse the
[xy}lim parameter?
-thomas
Cheers,
plot(x,y,ylim=c(0,max(y))) Does it work for you ? Cordialement. Romain. Dan Bolser a écrit :
Hi, I would like to bound the lower limit of my y scale to zero, and let R chose an upper limit. Something like plot(x,ylim=c(0,)) or plot(x,ylim=c(0,na)) but nither of these do the job. I searched the docs, but I can't see a way to do this. Naturally its nothing I can't do 'by hand', I would just like to know if a correct syntax exists.
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Thomas Lumley Assoc. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle
On Sun, 9 Jan 2005, Dan Bolser wrote:
Thats a good point. help.search("xlim") / ?xlim don't turn up any pages,
and only plot.default seems to document [xy]lim. Aside from greping the
source / docs how can I find out which plot functions use / abuse the
[xy}lim parameter?
That's actually good news. If a plot method doesn't document xlim/ylim then it's a reasonable bet that it either doesn't accept them or accepts them in ... and passes them to plot.default. -thomas