I am trying to simulate a minefield by plotting two Poisson distributed samples in the same plot, one with a higher intensity and smaller area than the other. This is the minefield and the other is just noise (stones, holes, metal) seen as points. I cannot get R to plot the points with the same units in the axis. Whatever I do, the points span the entire plot, even though I only want the X points to cover a quarter of the plot. My R-code is just the following:
library(spatstat)
Y = rpoispp(c(5),win=owin(c(0,10),c(0,10)))
X = rpoispp(c(10),win=owin(c(0,5),c(0,5)))
Please let me know if you can help me.
My guess is that you are doing something like:
to plot the points.
The problem with this is that the default behavior of the plot function for the class
ppp
(which is what therpoispp
function returns) is to create a new plot with just its points. So the secondplot
call essentially erases the first plot, and plots its own points in a differently scaled window. You can override this behavior by setting the optionadd=TRUE
for the second plot. So the codeshould get you something like:
Check out the docs (
help(plot.ppp)
) for more explanation and other options to prettify the plot.