1

I'm plotting a forest with trees as in the sample data lansing in spatstat. My code is as in this example:

plot(lansing, cols=rainbow(length(unique(lansing$marks))),
         leg.args=list(y.intersp = .5, cex = .2, pt.cex = .2))

But I have 14 tree species, so I receive the warning that only 10 are shown in the symbol map. Is there a way to show them all? I tried different ways, e.g. y.intersp, which brought no error, but also no response.

Any help is appreciated. Thank you!

Qiyuan
  • 109
  • 10

1 Answers1

2

The legend in plot.ppp() is also called a symbolmap and the plotting of the legend is done by plot.symbolmap() which defaults to only plotting 10 types of points. You can override it by setting nsymbols = 14. To set this argument from plot.ppp() you can use the argument leg.args:

library(spatstat)
X <- rmpoint(100, win = owin(), types = letters[1:14])
s <- plot(X, leg.args = list(nsymbols = 14))

The return value of plot.ppp() is the symbolmap used so you can reuse the same symbolmap in another plot. You can also plot the symbolmap itself:

plot(s, main = "", vertical = TRUE)
#> Warning: Only 10 out of 14 symbols are shown in the symbol map

plot(s, nsymbols = 14, main = "", vertical = TRUE)

Ege Rubak
  • 4,347
  • 1
  • 10
  • 18