@@ -18,6 +18,7 @@ persp.linim <- local({
1818 persp.linim <- function (x , ... , main , grid = TRUE , ngrid = 10 ,
1919 col.grid = " grey" , col.base = " white" ,
2020 neg.args = list (), warncross = FALSE ,
21+ zadjust = 1 ,
2122 extrapolate = c(" linear" , " constant" )) {
2223 xname <- short.deparse(substitute(x ))
2324 if (missing(main )) main <- xname
@@ -26,6 +27,13 @@ persp.linim <- local({
2627 # '
2728 L <- as.linnet(x )
2829 R <- Frame(L )
30+ # ' rescale function values to a scale commensurate with window
31+ # ' (to achieve appropriate default scale in persp.default)
32+ xmax <- max(abs(x ))
33+ if (rescaled <- (xmax > .Machine $ double.eps )) {
34+ scal <- max(sidelengths(R ))/ xmax
35+ x <- scal * x
36+ }
2937 zlim <- range(x , 0 )
3038 # ' set up perspective transformation and plot horizontal plane
3139 if (is.im(col.base )) {
@@ -36,7 +44,7 @@ persp.linim <- local({
3644 BaseInfo <- list (colin = col.base )
3745 } else if (is.colour(col.base )) {
3846 # ' Usual case: horizontal plane will be a single colour
39- Z <- as.im(0 , W = R , dimyx = ngrid )
47+ Z <- as.im(0 , W = R , dimyx = rev( ngrid ) )
4048 # ' Draw grid lines by setting 'border' argument of persp.default
4149 # ' provided the function has no negative values
4250 border <- if (grid && (zlim [1 ] > = 0 )) col.grid else NA
@@ -49,8 +57,10 @@ persp.linim <- local({
4957 BaseInfo ,
5058 dotargs ,
5159 list (axes = FALSE , box = FALSE ,
52- zlim = zlim , zlab = xname ,
53- scale = TRUE , expand = 0.1 ))
60+ zlim = zlim , zlab = xname ,
61+ scale = ! rescaled ,
62+ # ' expand=0.1 is default in persp.default
63+ expand = zadjust * 0.1 ))
5464 M <- do.call.matched(persp.im , argh ,
5565 extrargs = graphicsPars(" persp" ))
5666 # ' compute the projection of the linear network
0 commit comments