[R] Quadratcount() plotting in R spatstat

Adrian Baddeley adrian at maths.uwa.edu.au
Mon Apr 30 06:00:02 CEST 2007


"John" <baseballstrategy at googlemail.com> writes:

> I am trying to plot a quadratcount object over a ppp object in the spatstat
> package.

For queries about a particular package, please email the package authors. 

> I ultimately want to get something like this 
> http://bg9.imslab.co.jp/Rhelp/R-2.4.0/src/library/spatstat/man/images/big_quadratcount_001.png

This image was generated by running 
	   example(quadratcount)
You can read the source code that generated it, by typing
	   help(quadratcount). 

> When I plot the quadratcount output (a table) it plots a mosaic graph over
> the points (try this line for instance plot(Titanic, main ="plot(Titanic,
> main= *)")   ), not the quads I want.

Please include the exact code that you used when you had the problem.

`Titanic' is a table, not the output of `quadratcount',
so we would not expect `Titanic' to be plotted in the same way 
as the output of quadratcount.

The output of quadratcount is not a table; it belongs to the
two classes "table" and "quadratcount". When you print it, it is
displayed as a table. When you plot it (e.g. plot(quadratcount(X))), 
it is displayed using the method 'plot.quadratcount'. 

If 'X' is your point pattern, then
       plot(X)
will plot the point pattern X, then
       qX <- quadratcount(X, 4, 4)
will calculate the quadrat counts in a 4 x 4 grid of quadrats, 
and 
       plot(qX, add=TRUE)
will overplot the quadrat boundary lines and overprint the quadrat counts
as text numerals. Notice the argument `add=TRUE' which superimposes
the quadrat counts on the previous plot. 

If you only want to display the quadrat boundaries and not the counts,
then the last line should be replaced by
       plot(qX, add=TRUE, entries=NULL)

The code in example(quadratcount) shows how to get thicker lines
and change colours, etc.

Adrian Baddeley



More information about the R-help mailing list