plot.ppp {spatstat} | R Documentation |
Plot a two-dimensional spatial point pattern
## S3 method for class 'ppp' plot(x, main, ..., chars=NULL, cols=NULL, use.marks=TRUE, which.marks=1, add=FALSE, maxsize=NULL, markscale=NULL,zap=0.01)
x |
The spatial point pattern to be plotted.
An object of class |
main |
text to be displayed as a title above the plot. |
... |
extra arguments that will be passed to the plotting functions
|
chars |
plotting character(s) used to plot points. |
cols |
the colour(s) used to plot points. |
use.marks |
logical flag; if |
which.marks |
Index determining which column of marks to use,
if the marks of |
add |
logical flag; if |
maxsize |
maximum size of the circles/squares plotted
when |
markscale |
physical scale factor determining the sizes of the
circles/squares plotted when |
zap |
Fraction between 0 and 1.
When |
This is the plot
method for
point pattern datasets (of class "ppp"
, see ppp.object
).
First the observation window x$window
is plotted.
Then the points themselves are plotted,
in a fashion that depends on their marks,
as follows.
If the point pattern does not have marks, or if use.marks = FALSE
,
then the locations of all points will be plotted
using a single plot character
If x$marks
is a factor, then
each level of the factor is
represented by a different plot character.
If x$marks
is a numeric vector,
the marks are rescaled to the unit interval and
each point is represented by a circle
with radius proportional to the rescaled mark
(if the value is positive) or a square with side proportional
to the absolute value of the rescaled mark (if the value is negative).
If x$marks
is neither numeric nor a factor,
then each possible mark will be represented by a
different plotting character. The default is to
represent the ith smallest mark value by
points(..., pch=i)
.
Plotting of the window x$window
is performed by
plot.owin
. This plot may be modified
through the ...
arguments. In particular the
extra argument border
determines
the colour of the window.
Plotting of the points themselves is performed
by the function points
, except for the case of
continuous marks, where it is performed by symbols
.
Their plotting behaviour may be modified through the ...
arguments.
The argument chars
determines the plotting character
or characters used to display the points (in all cases except
for the case of continuous marks). For an unmarked point pattern,
this should be a single integer or character determining a
plotting character (see par("pch")
).
For a multitype point pattern, chars
should be a vector
of integers or characters, of the same length
as levels(x$marks)
, and then the ith level or type
will be plotted using character chars[i]
.
If chars
is absent, but there is an extra argument
pch
, then this will determine the plotting character for
all points.
The argument cols
determines the colour or colours used to
display the points. For an unmarked point pattern, or a
marked point pattern with continuous marks, this should be a character string
determining a colour. For a multitype point pattern, cols
should be a character vector, of the same length
as levels(x$marks)
. The ith level or type will
be plotted using colour cols[i]
.
If cols
is absent, the colour used to plot all the
points may be determined by the extra argument fg
(for multitype point patterns) or the extra argument col
(for all other cases). Note that col
will also reset the
colour of the window.
The arguments maxsize
and markscale
incompatible. They control the physical size of the circles and
squares which represent the marks in a point pattern with continuous
marks. If markscale
is given, then a mark value of m
is plotted as a circle of radius m * markscale
(if m
is positive) or a square of side abs(m) * markscale
(if m
is negative). If maxsize
is given, then the
largest mark in absolute value, mmax=max(abs(x$marks))
,
will be scaled to have physical size maxsize
.
The user can set the default values of these plotting parameters
using spatstat.options("par.points")
.
To zoom in (to view only a subset of the point pattern at higher
magnification), use the graphical arguments
xlim
and ylim
to specify the rectangular field of view.
The value returned by this plot function can be used to make a suitable legend, as shown in the examples.
NULL
, or a vector giving the correspondence between
mark values and plotting characters.
A frequently-asked question is: How do I remove the white space around
the plot? Currently plot.ppp
uses the base graphics system of
R, so the space around the plot is controlled by parameters
to par
. To reduce the white space, change the
parameter mar
. Typically, par(mar=rep(0.5, 4))
is
adequate, if there are no annotations or titles outside the window.
Adrian Baddeley Adrian.Baddeley@csiro.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner r.turner@auckland.ac.nz
iplot
,
ppp.object
,
plot
,
par
,
points
,
plot.owin
,
symbols
data(cells) plot(cells) plot(cells, pch=16) # make the plotting symbols larger (for publication at reduced scale) plot(cells, cex=2) # set it in spatstat.options oldopt <- spatstat.options(par.points=list(cex=2)) plot(cells) spatstat.options(oldopt) # multitype data(lansing) plot(lansing) # marked by a real number data(longleaf) plot(longleaf) # just plot the points plot(longleaf, use.marks=FALSE) plot(unmark(longleaf)) # equivalent # controlling COLOURS of points plot(cells, cols="blue") plot(lansing, cols=c("black", "yellow", "green", "blue","red","pink")) plot(longleaf, fg="blue") # make window purple plot(lansing, border="purple") # make everything purple plot(lansing, border="purple", cols="purple", col.main="purple") # controlling PLOT CHARACTERS plot(lansing, chars = 11:16) plot(lansing, chars = c("o","h","m",".","o","o")) # controlling MARK SCALE plot(longleaf, markscale=0.1) # draw circles of DIAMETER equal to nearest neighbour distance plot(cells %mark% nndist(cells), markscale=1/2) # making the legend data(amacrine) v <- plot(amacrine) legend(0.2, 1.2, pch=v, legend=names(v)) # point pattern with multiple marks data(finpines) plot(finpines, which.marks="height")