Skip to content

Commit

Permalink
Improvements to plotting of colour-only symbolmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed May 2, 2024
1 parent cae0f43 commit b814617
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spatstat.geom
Version: 3.2-9.015
Date: 2024-05-01
Version: 3.2-9.016
Date: 2024-05-02
Title: Geometrical Functionality of the 'spatstat' Family
Authors@R: c(person("Adrian", "Baddeley",
role = c("aut", "cre", "cph"),
Expand Down
6 changes: 5 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CHANGES IN spatstat.geom VERSION 3.2-9.015
CHANGES IN spatstat.geom VERSION 3.2-9.016

OVERVIEW

Expand Down Expand Up @@ -27,6 +27,10 @@ SIGNIFICANT USER-VISIBLE CHANGES
o plot.owin
New argument 'adj.main' controls the justification of the text
in the main title.

o plot.colourmap
New argument 'nticks' controls the number of axis tick marks
when the colourmap is defined on a continuous range of numerical values.

o plot.tess
Changed the default values for do.col and do.labels
Expand Down
22 changes: 18 additions & 4 deletions R/colourtables.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# support for colour maps and other lookup tables
#
# $Revision: 1.49 $ $Date: 2023/02/21 08:20:14 $
# $Revision: 1.51 $ $Date: 2024/05/02 03:50:40 $
#

colourmap <- function(col, ..., range=NULL, breaks=NULL, inputs=NULL, gamma=1) {
Expand Down Expand Up @@ -229,11 +229,25 @@ plot.colourmap <- local({
} else stop("Unrecognised format for 'side'")
return(sidecode)
}

Ticks <- function(usr, log=FALSE, nint=NULL, ..., clip=TRUE) {
#' modification of grDevices::axisTicks
#' constrains ticks to be inside the specified range 'usr' if clip=TRUE
#' accepts nint=NULL as if it were missing
z <- if(is.null(nint)) axisTicks(usr=usr, log=log, ...) else
axisTicks(usr=usr, log=log, nint=nint, ...)
if(clip) {
zlimits <- if(log) 10^usr else usr
z <- z[inside.range(z, zlimits)]
}
return(z)
}


plot.colourmap <- function(x, ..., main,
xlim=NULL, ylim=NULL, vertical=FALSE, axis=TRUE,
labelmap=NULL, gap=0.25, add=FALSE,
increasing=NULL) {
increasing=NULL, nticks=5) {
if(missing(main))
main <- short.deparse(substitute(x))
stuff <- attr(x, "stuff")
Expand Down Expand Up @@ -397,7 +411,7 @@ plot.colourmap <- local({
la <- paste(labelmap(stuff$inputs))
at <- linmap(v, rr, xlim)
} else {
la <- prettyinside(rr)
la <- Ticks(rr, nint=nticks)
at <- linmap(la, rr, xlim)
la <- labelmap(la)
}
Expand Down Expand Up @@ -425,7 +439,7 @@ plot.colourmap <- local({
la <- paste(labelmap(stuff$inputs))
at <- linmap(v, rr, ylim)
} else {
la <- prettyinside(rr)
la <- Ticks(rr, nint=nticks)
at <- linmap(la, rr, ylim)
la <- labelmap(la)
}
Expand Down
6 changes: 5 additions & 1 deletion R/plot.ppp.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# plot.ppp.R
#
# $Revision: 1.121 $ $Date: 2024/04/26 01:04:19 $
# $Revision: 1.122 $ $Date: 2024/05/02 04:14:14 $
#
#
#--------------------------------------------------------------------------
Expand Down Expand Up @@ -151,7 +151,11 @@ plot.ppp <- function(x, main, ..., clipwin=NULL,
leg.args <- append(list(side=leg.side, vertical=vertical), leg.args)
if(isTRUE(leg.args$colour.only)) {
## only the colour map will be plotted
## use layout similar to plot.im
sizeguess <- NULL
leg.args <- resolve.defaults(leg.args, list(sep.frac=0.15,
size.frac=0.05,
las=1))
} else {
## symbols will be plotted
## guess maximum size of symbols
Expand Down
2 changes: 1 addition & 1 deletion inst/doc/packagesizes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ date version nhelpfiles nobjects ndatasets Rlines srclines
"2023-10-20" "3.2-7" 451 1203 0 35983 15822
"2024-01-26" "3.2-8" 452 1204 0 36234 15822
"2024-02-28" "3.2-9" 452 1209 0 36325 15824
"2024-05-01" "3.2-9.015" 443 1188 0 35694 15596
"2024-05-02" "3.2-9.016" 443 1188 0 35712 15596
14 changes: 9 additions & 5 deletions man/plot.colourmap.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
\usage{
\method{plot}{colourmap}(x, ...,
main, xlim = NULL, ylim = NULL, vertical = FALSE, axis = TRUE,
labelmap=NULL, gap=0.25, add=FALSE, increasing=NULL)
labelmap=NULL, gap=0.25, add=FALSE, increasing=NULL, nticks=5)
}
\arguments{
\item{x}{Colour map to be plotted. An object of class \code{"colourmap"}.}
Expand Down Expand Up @@ -50,6 +50,12 @@
Logical value indicating whether to display the colour map
in increasing order. See Details.
}
\item{nticks}{
Optional. Integer specifying the approximate number of tick marks
(representing different values of the numerical input) that should be
drawn next to the colour map. Applies only when the colour map
inputs are numeric values.
}
}
\details{
This is the plot method for the class \code{"colourmap"}.
Expand Down Expand Up @@ -100,11 +106,9 @@
ca <- colourmap(rainbow(8), inputs=letters[1:8])
plot(ca, vertical=TRUE)
}
\author{\adrian


\author{
\adrian
and \rolf

}
\keyword{spatial}
\keyword{color}
Expand Down

0 comments on commit b814617

Please sign in to comment.