[R] plot.default and open ended limits

Romain François francoisromain at free.fr
Sun Jan 9 21:32:12 CET 2005


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/




More information about the R-help mailing list