Skip to content

Commit 1699ca6

Browse files
committed
Further improvements to persp.linim
1 parent 8260859 commit 1699ca6

File tree

6 files changed

+33
-8
lines changed

6 files changed

+33
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: spatstat.linnet
2-
Version: 3.4-0.004
2+
Version: 3.4-0.006
33
Date: 2025-12-12
44
Title: Linear Networks Functionality of the 'spatstat' Family
55
Authors@R: c(person("Adrian", "Baddeley",

NEWS

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
CHANGES IN spatstat.linnet VERSION 3.4-0.004
2+
CHANGES IN spatstat.linnet VERSION 3.4-0.006
33

44
OVERVIEW
55

@@ -19,7 +19,10 @@ SIGNIFICANT USER-VISIBLE CHANGES
1919
o persp.linim
2020
Argument 'col.base' can be a pixel image, allowing a colour image
2121
to be plotted on the horizontal plane at height zero.
22-
22+
23+
o persp.linim
24+
New argument 'zadjust' to control vertical scale.
25+
2326
CHANGES IN spatstat.linnet VERSION 3.4-0
2427

2528
OVERVIEW

R/perspex.R

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

inst/doc/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
4242
"2025-07-24" "3.3-1" 150 328 0 13326 3270
4343
"2025-09-24" "3.3-2" 150 328 0 13356 3270
4444
"2025-11-29" "3.4-0" 160 370 0 14990 3270
45-
"2025-12-12" "3.4-0.004" 160 371 0 15166 3270
45+
"2025-12-12" "3.4-0.006" 160 371 0 15176 3270

inst/info/packagesizes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
4242
"2025-07-24" "3.3-1" 150 328 0 13326 3270
4343
"2025-09-24" "3.3-2" 150 328 0 13356 3270
4444
"2025-11-29" "3.4-0" 160 370 0 14990 3270
45-
"2025-12-12" "3.4-0.004" 160 371 0 15166 3270
45+
"2025-12-12" "3.4-0.006" 160 371 0 15176 3270

man/persp.linim.Rd

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
grid = TRUE, ngrid = 10,
1212
col.grid = "grey", col.base = "white",
1313
neg.args=list(), warncross=FALSE,
14+
zadjust=1,
1415
extrapolate=c("linear", "constant"))
1516
}
1617
\arguments{
@@ -50,6 +51,9 @@
5051
two segments of the network cross each other (which causes
5152
difficulty for the algorithm).
5253
}
54+
\item{zadjust}{
55+
Adjustment factor for vertical scale, relative to the default scale.
56+
}
5357
\item{extrapolate}{
5458
Character string (partially matched) specifying how to extrapolate
5559
the value at the endpoint of each segment.
@@ -100,6 +104,14 @@
100104
other than white, or if \code{col.base} is a pixel image.
101105
A transparent colour for \code{col.base} can be used
102106
if it is supported by the graphics device.
107+
108+
Like all spatial plots in the \pkg{spatstat} family,
109+
\code{persp.linim} does not independently rescale
110+
the \eqn{x} and \eqn{y} coordinates. A long narrow window will be
111+
represented as a long narrow window in the perspective view.
112+
To override this and allow the coordinates to be independently
113+
rescaled, use the argument \code{scale=TRUE} which will be passed
114+
to \code{\link[graphics]{persp.default}}.
103115
}
104116
\value{
105117
(Invisibly) the perspective transformation matrix,

0 commit comments

Comments
 (0)