Skip to content

Commit

Permalink
plot.symbolmap has new argument 'representatives'
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Jan 15, 2024
1 parent 31cac21 commit 6c36d8b
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: spatstat.geom
Version: 3.2-7.005
Version: 3.2-7.006
Date: 2024-01-15
Title: Geometrical Functionality of the 'spatstat' Family
Authors@R: c(person("Adrian", "Baddeley",
Expand Down
10 changes: 8 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
CHANGES IN spatstat.geom VERSION 3.2-7.005
CHANGES IN spatstat.geom VERSION 3.2-7.006

OVERVIEW

o Minor improvements.
o Improvements to window geometry code.

o Improvements to symbol map displays.

SIGNIFICANT USER-VISIBLE CHANGES

Expand All @@ -18,6 +20,10 @@ SIGNIFICANT USER-VISIBLE CHANGES
New argument 'zerosize' specifies the size of the symbol
used to represent the mark value 0, when marks are numeric.

o plot.symbolmap
New argument 'representatives' specifies which data values
will be shown in the plot.

CHANGES IN spatstat.geom VERSION 3.2-7

OVERVIEW
Expand Down
52 changes: 43 additions & 9 deletions R/symbolmap.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
## symbolmap.R
##
## $Revision: 1.46 $ $Date: 2023/02/21 08:09:47 $
## $Revision: 1.47 $ $Date: 2024/01/15 05:34:44 $
##

symbolmap <- local({
Expand Down Expand Up @@ -480,7 +480,7 @@ plot.symbolmap <- function(x, ..., main,
side=c("bottom", "left", "top", "right"),
annotate=TRUE, labelmap=NULL, add=FALSE,
nsymbols=NULL, warn=TRUE,
colour.only=FALSE) {
colour.only=FALSE, representatives=NULL) {
if(missing(main))
main <- short.deparse(substitute(x))
miss.side <- missing(side)
Expand Down Expand Up @@ -523,17 +523,51 @@ plot.symbolmap <- function(x, ..., main,
},
continuous = {
ra <- stuff$range
if(is.null(ra))
stop("Cannot plot symbolmap with an infinite range")
vv <- if(is.null(nsymbols)) prettyinside(ra) else
if(!is.null(representatives)) {
vv <- representatives
if(!all(ok <- inside.range(vv, ra))) {
nbad <- sum(!ok)
vv <- vv[ok]
warning(paste(nbad, "out of", length(vv),
ngettext(nbad, "value", "values"),
"in the argument",
sQuote("representatives"),
ngettext(nbad, "was", "were"),
"outside the range of the symbol map, and",
ngettext(nbad, "was", "were"),
"removed"),
call.=FALSE)
}
} else {
if(is.null(ra))
stop("Cannot plot symbolmap with an infinite range")
vv <- if(is.null(nsymbols)) prettyinside(ra) else
prettyinside(ra, n = nsymbols)
if(is.numeric(vv))
vv <- signif(vv, 4)
if(is.numeric(vv))
vv <- signif(vv, 4)
}
},
discrete = {
dd <- stuff$inputs
vv <- if(is.null(nsymbols)) prettydiscrete(dd) else
prettydiscrete(dd, n = nsymbols)
if(!is.null(representatives)) {
vv <- representatives
if(!all(ok <- vv %in% dd)) {
nbad <- sum(!ok)
vv <- vv[ok]
warning(paste(nbad, "out of", length(vv),
ngettext(nbad, "value", "values"),
"in the argument",
sQuote("representatives"),
ngettext(nbad, "was", "were"),
"outside the domain of the symbol map, and",
ngettext(nbad, "was", "were"),
"removed"),
call.=FALSE)
}
} else {
vv <- if(is.null(nsymbols)) prettydiscrete(dd) else
prettydiscrete(dd, n = nsymbols)
}
if(warn && (length(vv) < length(dd))) {
warning(paste("Only", length(vv), "out of", length(dd),
"symbols are shown in the symbol map"),
Expand Down
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2023-09-05" "3.2-5" 450 1203 0 35948 15822
"2023-10-19" "3.2-6" 451 1203 0 35983 15822
"2023-10-20" "3.2-7" 451 1203 0 35983 15822
"2024-01-15" "3.2-7.005" 452 1204 0 36191 15822
"2024-01-15" "3.2-7.006" 452 1204 0 36225 15822
10 changes: 9 additions & 1 deletion man/plot.symbolmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
vertical = FALSE,
side = c("bottom", "left", "top", "right"),
annotate = TRUE, labelmap = NULL, add = FALSE,
nsymbols = NULL, warn = TRUE, colour.only=FALSE)
nsymbols = NULL, warn = TRUE,
colour.only=FALSE,
representatives=NULL)
}
\arguments{
\item{x}{
Expand Down Expand Up @@ -50,6 +52,7 @@
}
\item{nsymbols}{
Optional. The maximum number of symbols that should be displayed.
Ignored if \code{representatives} are given.
}
\item{warn}{
Logical value specifying whether to issue a warning
Expand All @@ -63,6 +66,10 @@
plotted, including information about symbol shape and size as well
as colour.
}
\item{representatives}{
Optional. Vector containing the values of the input data
which should be shown on the plot.
}
}
\details{
A graphics symbol map (object of class \code{"symbolmap"})
Expand Down Expand Up @@ -104,6 +111,7 @@
size=function(x) sqrt(ifelse(x > 0, x/pi, -x)),
bg = function(x) ifelse(abs(x) < 1, "red", "black"))
plot(g2, vertical=TRUE, side="left", col.axis="blue", cex.axis=2)
plot(g2, representatives=c(-1,0,1))
}
\keyword{spatial}
\keyword{hplot}

0 comments on commit 6c36d8b

Please sign in to comment.