Search code examples
rspatstat

How do I remove the title from a Kcross plot?


I'd like to plot a Kcross() plot in R and I'm having trouble removing main. I've tried main="", main=NULL and adjusting the mar=c() so it won't show the title, but none of that seems to be working properly. The problem pops up when I'm working with Kcross(), Jcross(), etc., on any other plot main="" works just fine. Any ideas?

kfunkcrossA <- alltypes(combinedA,Kcross,correction="border")

pdf(file = paste0(resultspath,var,"/kfunkcross",var,".pdf"),width = 5, height=3, family="CM Roman")
par(mar=c(2,2,2,2))
plot(kfunkcrossA,.-r~r,main=NULL)
dev.off()

Solution

  • You are actually estimating Kcross for all combinations of types in your data. The result of alltypes() is an object of class fasp (Function Arrays for Spatial Patterns). When you use the generic plot() function it dispatches to plot.fasp(). The help file for plot.fasp() tells you that the correct argument name is title. In lack of your data is an example with built-in data:

    library(spatstat)
    #> Loading required package: spatstat.data
    #> Loading required package: spatstat.geom
    #> spatstat.geom 2.1-0.002
    #> Loading required package: spatstat.core
    #> Loading required package: nlme
    #> Loading required package: rpart
    #> spatstat.core 2.1-2.004
    #> Loading required package: spatstat.linnet
    #> spatstat.linnet 2.1-1.002
    #> 
    #> spatstat 2.1-0       (nickname: 'Comedic violence') 
    #> For an introduction to spatstat, type 'beginner'
    combinedA <- amacrine # Use built-in data
    kfunkcrossA <- alltypes(combinedA, Kcross, correction="border")
    class(kfunkcrossA) # Class fasp
    #> [1] "fasp"
    plot(kfunkcrossA, .-r~r, title="") # Calling plot.fasp()