Skip to content

Commit

Permalink
Improvements to persp.ppp
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Oct 28, 2024
1 parent f1f6001 commit f3cf22c
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 18 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spatstat.geom
Version: 3.3-3.004
Date: 2024-10-24
Version: 3.3-3.005
Date: 2024-10-28
Title: Geometrical Functionality of the 'spatstat' Family
Authors@R: c(person("Adrian", "Baddeley",
role = c("aut", "cre", "cph"),
Expand All @@ -25,7 +25,7 @@ Authors@R: c(person("Adrian", "Baddeley",
person("Rasmus", "Waagepetersen", role = "ctb"))
Maintainer: Adrian Baddeley <[email protected]>
Depends: R (>= 3.5.0), spatstat.data (>= 3.1), spatstat.univar (>= 3.0-0), stats, graphics, grDevices, utils, methods
Imports: spatstat.utils (>= 3.1-0), deldir (>= 1.0-2), polyclip (>= 1.10-0)
Imports: spatstat.utils (>= 3.1-0.001), deldir (>= 1.0-2), polyclip (>= 1.10-0)
Suggests: spatstat.random, spatstat.explore, spatstat.model, spatstat.linnet, spatial, fftwtools (>= 0.9-8), spatstat (>= 3.0)
Description: Defines spatial data types and supports geometrical operations
on them. Data types include point patterns, windows (domains),
Expand Down
8 changes: 6 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHANGES IN spatstat.geom VERSION 3.3-3.004
CHANGES IN spatstat.geom VERSION 3.3-3.005

OVERVIEW

Expand All @@ -19,9 +19,13 @@ SIGNIFICANT USER-VISIBLE CHANGES
Now accepts arguments passed to 'as.mask' to control the pixel resolution.

o persp.ppp
Now draws a reference scale bar for the vertical scale.
Now draws a reference scale bar for the vertical scale, by default.
New arguments 'legend', 'legendpos', 'leg.args', 'leg.col'.

o persp.ppp
Optionally draws a symbol at the top of each spike.
New arguments 'type', 'point.args'.

CHANGES IN spatstat.geom VERSION 3.3-3

OVERVIEW
Expand Down
36 changes: 29 additions & 7 deletions R/persp.ppp.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
#' Copyright (C) Adrian Baddeley 2024
#' GPL Public Licence >= 2.0
#'
#' $Revision: 1.4 $ $Date: 2024/10/24 03:32:24 $
#' $Revision: 1.5 $ $Date: 2024/10/28 06:10:01 $

persp.ppp <- local({

persp.ppp <- function(x, ..., main, grid=TRUE, ngrid=10,
persp.ppp <- function(x, ..., main, type=c("l", "b"), grid=TRUE, ngrid=10,
col.grid="grey", col.base="white",
win.args=list(),
spike.args=list(),
neg.args=list(), which.marks=1,
spike.args=list(),
neg.args=list(), point.args=list(), which.marks=1,
zlab=NULL, zlim=NULL,
zadjust=1,
legend=TRUE, legendpos="bottomleft",
leg.args=list(lwd=4),
leg.col=c("black", "orange")) {
if(missing(main)) main <- short.deparse(substitute(x))
type <- match.arg(type)
W <- Window(x)
R <- Frame(x)
marx <- marks(x)
Expand Down Expand Up @@ -85,14 +86,23 @@ persp.ppp <- local({
#' create spikes
S <- xyzsegmentdata(x$x, x$y, 0,
x$x, x$y, scaled.marx)
#' and bubbles
if(type == "b")
P <- data.frame(x=x$x, y=x$y, z=scaled.marx)

if(grid) {
if(scaled.zlim[1] < 0) {
#' first draw downward spikes
downward <- (scaled.marx < 0)
if(any(downward)) {
SD <- S[downward, , drop=FALSE]
spectiveSegments(SD, neg.args, spike.args, ..., M=M)
spectiveSegments(SD, neg.args, spike.args, dotargs, M=M)
S <- S[!downward, , drop=FALSE]
if(type == "b") {
PD <- P[downward, , drop=FALSE]
spectivePoints(PD, point.args, dotargs, M=M)
P <- P[!downward, , drop=FALSE]
}
}
#' plot baseline grid
spectiveFlatGrid(R, ngrid, M, col=col.grid)
Expand All @@ -105,6 +115,8 @@ persp.ppp <- local({
#' draw upward spikes
if(nrow(S) > 0) {
spectiveSegments(S, spike.args, dotargs, M=M)
if(type == "b")
spectivePoints(P, point.args, dotargs, M=M)
}
#'
if(legend) {
Expand Down Expand Up @@ -134,7 +146,7 @@ persp.ppp <- local({
tixseg <- xyzsegmentdata(legxy[1], legxy[2], scaled.tix[-ntix],
legxy[1], legxy[2], scaled.tix[-1])
tixcol <- rep(leg.col, ntix)[1:ntix]
spectiveSegments(tixseg, list(col=tixcol), leg.args, spike.args, M=M)
spectiveSegments(tixseg, list(col=tixcol), leg.args, M=M)
spectiveText(legxy[1], legxy[2], scaled.tix[-c(1,ntix)],
labels=tix[-c(1,ntix)], pos=4, M=M)
}
Expand Down Expand Up @@ -195,11 +207,21 @@ persp.ppp <- local({
invisible(NULL)
}

spectivePoints <- function(df, ..., M) {
## arguments ... should be lists of parameters
p <- with(df, trans3dz(x, y, z, M))
do.call.matched(points.default,
resolve.defaults(
list(x=p$x, y=p$y),
...),
extrargs=graphicsPars("points"))
}

spectiveText <- function(x,y,z, ..., M) {
p <- trans3dz(x, y, z, M)
text(p$x, p$y, ...)
}

persp.ppp
})

Expand Down
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2024-07-05" "3.3-0" 442 1186 0 35638 15596
"2024-07-09" "3.3-2" 442 1186 0 35638 15596
"2024-09-18" "3.3-3" 443 1187 0 35818 15596
"2024-10-24" "3.3-3.004" 443 1188 0 35936 15596
"2024-10-28" "3.3-3.005" 443 1188 0 35958 15596
2 changes: 1 addition & 1 deletion inst/info/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2024-07-05" "3.3-0" 442 1186 0 35638 15596
"2024-07-09" "3.3-2" 442 1186 0 35638 15596
"2024-09-18" "3.3-3" 443 1187 0 35818 15596
"2024-10-24" "3.3-3.004" 443 1188 0 35936 15596
"2024-10-28" "3.3-3.005" 443 1188 0 35958 15596
28 changes: 24 additions & 4 deletions man/persp.ppp.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
shown as a vertical spike, with height proportional to the mark value.
}
\usage{
\method{persp}{ppp}(x, \dots, main, grid = TRUE, ngrid = 10,
\method{persp}{ppp}(x, \dots, main, type=c("l", "b"),
grid = TRUE, ngrid = 10,
col.grid = "grey", col.base = "white",
win.args=list(), spike.args = list(), neg.args = list(),
which.marks = 1, zlab = NULL, zlim = NULL, zadjust = 1,
win.args=list(),
spike.args = list(), neg.args = list(),
point.args=list(),
which.marks = 1,
zlab = NULL, zlim = NULL, zadjust = 1,
legend=TRUE, legendpos="bottomleft",
leg.args=list(lwd=4), leg.col=c("black", "orange"))
}
Expand All @@ -27,11 +31,18 @@
(for example the rotation angle \code{theta} and the elevation angle
\code{phi})
or passed to \code{\link[graphics]{segments}} to control the drawing
(for example \code{lwd} for line width).
of lines (for example \code{lwd} for line width)
or passed to \code{\link[graphics]{points.default}} to control the drawing
of points (for example \code{pch} for symbol type).
}
\item{main}{
Optional main title for the plot.
}
\item{type}{
Single character specifying how each observation will be plotted:
\code{type="l"} for lines,
\code{type="b"} for both lines and points.
}
\item{grid}{
Logical value specifying whether to draw a grid of reference lines
on the horizontal plane.
Expand Down Expand Up @@ -61,6 +72,10 @@
applicable only to those spikes which have negative height
(corresponding to a mark value which is negative).
}
\item{point.args}{
List of arguments passed to \code{\link[graphics]{points.default}}
to control the drawing of the points, when \code{type="b"}.
}
\item{which.marks}{
Integer, or character name, identifying the column of marks which
should be used, when \code{marks(x)} is a data frame.
Expand Down Expand Up @@ -153,6 +168,11 @@ Adrian Baddeley.
win.args=list(col="pink", border=NA),
spike.args=list(lwd=2), zadjust=1.5)

persp(Y, type="b",
theta=30, phi=20, col.base="lightblue",
win.args=list(col="pink", border=NA),
spike.args=list(lty=3), point.args=list(col="blue"), zadjust=1.5)

}
\keyword{hplot}
\keyword{spatial}

0 comments on commit f3cf22c

Please sign in to comment.