Dear R developers,

I would like to have R choose the limits of the y-axis semi-automatically,
e.g., zero should be included, but the maximum should be chosen depending 
on the data.

Examples:

plot(1:10, 1:10) # selects min and max automatically
plot(1:10, 1:10, ylim=c(1, 10)) # manual definition
plot(1:10, 1:10, ylim=c(0, Inf)) # this would be a nice feature, i.e. lower y 
limit = 0 defined manually, upper limit = 10 selected automatically

The relevant code from plot.default would have to be modified:

old:

ylim <- if (is.null(ylim)) 
        range(xy$y[is.finite(xy$y)])
    else ylim

new:

ylim <- if (is.null(ylim)) 
        range(xy$y[is.finite(xy$y)])
    else if(length(ylim) == 2 & ylim[2] == Inf)
            c(ylim[1], max(xy$y[is.finite(xy$y)])
        else ylim

and some more if-else statements if cases like ylim=c(0, -Inf), 
ylim=c(Inf, 0), ylim=c(-Inf, 0) and ylim=c(-Inf, Inf)[as a replacement for NULL/
autoselection] and ylim=c(Inf, -Inf)[autoselection, reversed y axis] should be 
handled correctly.

I would find such a feature useful. Do you think it would interfere with other 
functions? 

Thank you for your consideration.

Best wishes,

Matthias Gondan

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to