[R] Character type and size using spatstats

Rolf Turner r.turner at auckland.ac.nz
Fri May 16 03:16:16 CEST 2014


Dear Patrick,

OK.  I think I have figured out what you are trying to do.

You want:

    * each "type" of point (where type is the corresponding
      level of "Concept") to be represented by a different symbol,

    * the size of the symbol to be determined by the value of "New".

The "maxsize" argument, as I think the help for plot.ppp() makes clear, 
*only* controls the size of the symbols (circles and squares) used when 
the marks involved are numeric.  If the marks are a factor then the 
points are plotted using the points() function, with a different 
plotting character for each level of the factor, but "maxsize" has no 
effect on the size of the character plotted.

The spatstat package has no facility explicitly aimed at controlling the 
size of "general" plotted characters.

The size of plotted characters can be controlled to some extent by using 
the "cex" argument that can be supplied to the built-in graphics 
functions in R, but it's a bit kludgy.

I experimented with various options to try to get a perspicuous plot. 
The following code is the best (none too good) that I could come up 
with.  Note that I made a selection of plotting characters that seemed 
"appealing" to my eye.  Note also that one entry of "Concept" was the 
null string "", which seemed to me to be undesirable so I change it to 
be a visible string. :-)

L    <- levels(bb9$Concept)
L[1] <- "WTF"
M    <- factor(bb9$Concept,labels=L)
X    <- with(bb9, ppp(ColN, Row, window = all.win, marks = M))
CEX  <- round(log(1+bb9[,"New"]))/2
CHA  <- c(18,20:23,1)
plot(X,cols="red",chars=CHA,which.marks="Concept",cex=CEX)

It is not clear to me why you are using spatstat here.  Of course 
spatstat is *wonderful* but it is aimed at answering questions about 
spatial point processes.  Your data appear to be the result of 
distributing plants in a field, in a more-or-less orderly and 
predetermined fashion rather than being the result of some random 
process.  But I could be misinterpreting what I see.

cheers,

Rolf



More information about the R-help mailing list