Skip to content

Commit

Permalink
Improvements to plot.imlist
Browse files Browse the repository at this point in the history
  • Loading branch information
baddstats committed Nov 28, 2024
1 parent 13b44e8 commit aeb8232
Show file tree
Hide file tree
Showing 13 changed files with 243 additions and 77 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.3-4.002
Date: 2024-11-22
Version: 3.3-4.003
Date: 2024-11-28
Title: Geometrical Functionality of the 'spatstat' Family
Authors@R: c(person("Adrian", "Baddeley",
role = c("aut", "cre", "cph"),
Expand Down
20 changes: 17 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CHANGES IN spatstat.geom VERSION 3.3-4.002
CHANGES IN spatstat.geom VERSION 3.3-4.003

OVERVIEW

o We thank Stephanie Hogg for contributions.

o Tweaks to plot.im

o Improvements to plotting of images, and arrays of images.

o Bug fix

SIGNIFICANT USER-VISIBLE CHANGES
Expand All @@ -14,6 +14,20 @@ SIGNIFICANT USER-VISIBLE CHANGES
New argument 'drop.ribbon' determines whether a ribbon will be displayed
in the case where the pixel values are all equal.
Default behaviour has changed.

o plot.imlist, image.imlist, image.listof
If equal.ribbon=TRUE and equal.scales=TRUE, the colour ribbon
is now neatly aligned with the plotted images.

o plot.solist, plot.anylist
Arguments 'adorn.left', 'adorn.right', 'adorn.bottom', 'adorn.top'
may now be objects of class 'colourmap' or 'symbolmap'.

o plot.solist, plot.anylist
New argument 'adorn.args'.

o plot.imlist, image.imlist, image.listof
New argument 'equal.scales'.

BUG FIXES

Expand Down
67 changes: 40 additions & 27 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.52 $ $Date: 2024/05/02 06:19:31 $
# $Revision: 1.61 $ $Date: 2024/11/28 01:51:29 $
#

colourmap <- function(col, ..., range=NULL, breaks=NULL, inputs=NULL, gamma=1) {
Expand Down Expand Up @@ -245,11 +245,21 @@ plot.colourmap <- local({


plot.colourmap <- function(x, ..., main,
xlim=NULL, ylim=NULL, vertical=FALSE, axis=TRUE,
xlim=NULL, ylim=NULL,
vertical=FALSE,
axis=TRUE,
side = if(vertical) "right" else "bottom",
labelmap=NULL, gap=0.25, add=FALSE,
increasing=NULL, nticks=5, box=NULL) {
if(missing(main))
main <- short.deparse(substitute(x))
if(missing(vertical) && !missing(side))
vertical <- (sideCode(side) %in% c(2, 4))

dotargs <- list(...)
if(inherits(dotargs$col, "colourmap"))
dotargs <- dotargs[names(dotargs) != "col"]

stuff <- attr(x, "stuff")
col <- stuff$outputs
n <- stuff$n
Expand Down Expand Up @@ -325,7 +335,7 @@ plot.colourmap <- local({
type="n", main=main,
axes=FALSE, xlab="", ylab="",
asp=1.0),
list(...)))
dotargs))

if(separate) {
# ................ plot separate blocks of colour .................
Expand All @@ -342,11 +352,11 @@ plot.colourmap <- local({
do.call.matched(image.default,
resolve.defaults(list(x=ensurenumeric(x),
y=ensurenumeric(y),
z=z, add=TRUE),
list(...),
list(col=col[i])),
extrargs=imageparams)

z=z,
add=TRUE,
col=col[i]),
dotargs),
extrargs=imageparams)
}
} else {
# vertical arrangement of blocks
Expand All @@ -359,11 +369,11 @@ plot.colourmap <- local({
do.call.matched(image.default,
resolve.defaults(list(x=ensurenumeric(x),
y=ensurenumeric(y),
z=z, add=TRUE),
list(...),
list(col=col[i])),
extrargs=imageparams)

z=z,
add=TRUE,
col=col[i]),
dotargs),
extrargs=imageparams)
}
}
} else {
Expand Down Expand Up @@ -397,10 +407,11 @@ plot.colourmap <- local({
if(reverse)
col <- rev(col)
do.call.matched(image.default,
resolve.defaults(list(x=x, y=y, z=z, add=TRUE),
list(...),
list(breaks=ensurenumeric(bks),
col=col)),
resolve.defaults(list(x=x, y=y, z=z,
add=TRUE,
breaks=ensurenumeric(bks),
col=col),
dotargs),
extrargs=imageparams)
}
#' draw box around colours?
Expand All @@ -424,20 +435,21 @@ plot.colourmap <- local({
if(reverse)
at <- rev(at)
# default axis position is below the ribbon (side=1)
side <- resolve.1.default("side", list(...), list(side=1L))
sidecode <- sideCode(side)
if(!(sidecode %in% c(1L,3L)))
warning(paste("side =", sidecode,
warning(paste("side =",
if(is.character(side)) sQuote(side) else side,
"is not consistent with horizontal orientation"))
pos <- c(ylim[1L], xlim[1L], ylim[2L], xlim[2L])[sidecode]
# don't draw axis lines if plotting separate blocks
lwd0 <- if(separate) 0 else 1
# draw axis
do.call.matched(graphics::axis,
resolve.defaults(list(...),
list(side = 1L, pos = pos,
at = ensurenumeric(at)),
list(labels=la, lwd=lwd0)),
list(side = sidecode,
pos = pos,
at = ensurenumeric(at),
labels=la, lwd=lwd0)),
extrargs=axisparams)
} else {
# add vertical axis
Expand All @@ -452,10 +464,10 @@ plot.colourmap <- local({
if(reverse)
at <- rev(at)
# default axis position is to the right of ribbon (side=4)
side <- resolve.1.default("side", list(...), list(side=4))
sidecode <- sideCode(side)
if(!(sidecode %in% c(2L,4L)))
warning(paste("side =", sidecode,
warning(paste("side =",
if(is.character(side)) sQuote(side) else side,
"is not consistent with vertical orientation"))
pos <- c(ylim[1L], xlim[1L], ylim[2L], xlim[2L])[sidecode]
# don't draw axis lines if plotting separate blocks
Expand All @@ -465,9 +477,10 @@ plot.colourmap <- local({
# draw axis
do.call.matched(graphics::axis,
resolve.defaults(list(...),
list(side=4, pos=pos,
at=ensurenumeric(at)),
list(labels=la, lwd=lwd0, las=las0)),
list(side=sidecode,
pos=pos,
at=ensurenumeric(at),
labels=la, lwd=lwd0, las=las0)),
extrargs=axisparams)
}
}
Expand Down
Loading

0 comments on commit aeb8232

Please sign in to comment.