plot.owin {spatstat} | R Documentation |
Plot a two-dimensional window of observation for a spatial point pattern
## S3 method for class 'owin' plot(x, main, add=FALSE, ..., box, edge=0.04, hatch=FALSE, angle=45, spacing=diameter(x)/50, invert=FALSE)
x |
The window to be plotted.
An object of class |
main |
text to be displayed as a title above the plot. |
add |
logical flag: if |
... |
extra arguments passed to the generic |
box |
logical flag; if |
edge |
nonnegative number; the plotting region will have coordinate limits
that are |
hatch |
logical flag; if |
angle |
orientation of the shading lines (in degrees anticlockwise
from the x axis) when |
spacing |
spacing between the shading lines,
when |
invert |
logical flag; when the window is a binary pixel mask,
the mask colours will be inverted if |
This is the plot
method for the class owin
.
The action is to plot the boundary of the window on the current plot device,
using equal scales on the x
and y
axes.
If the window x
is of type "rectangle"
or "polygonal"
,
the boundary of the window is plotted as a polygon or series of polygons.
If x
is of type "mask"
the discrete raster approximation of the window is displayed
as a binary image (white inside the window, black outside).
Graphical parameters controlling the display (e.g. setting the
colours) may be passed directly via the ...
arguments,
or indirectly reset using
spatstat.options
.
When x
is of type "rectangle"
or "polygonal"
, it
is plotted by the R function polygon
. To control the
appearance (colour, fill density, line density etc) of the polygon
plot, determine the required argument of polygon
and
pass it through ...
For example, to paint the interior of the
polygon in red, use the argument col="red"
. To draw the polygon
edges in green, use border="green"
. To suppress the drawing of
polygon edges, use border=NA
.
When x
is of type "mask"
, it is plotted by
image.default
. The appearance of the image plot
can be controlled by passing arguments to image.default
through ...
. The default appearance can also be changed
by setting the parameter par.binary
of
spatstat.options
.
To zoom in (to view only a subset of the window at higher
magnification), use the graphical arguments
xlim
and ylim
to specify the desired rectangular field of
view. (The actual field of view may be larger, depending on the
graphics device).
none.
The function polygon
can only handle
polygons without holes. To plot polygons with holes in a solid colour,
we have implemented two workarounds.
The first workaround uses
the relatively new function polypath
which
does have the capability to handle polygons with holes.
However, not all graphics devices support polypath
.
The older devices xfig
and pictex
do not support polypath
.
On a Windows system, the default graphics device
windows
supports polypath
.
On a Linux system, the default graphics device
X11(type="Xlib")
does not support polypath
but X11(type="cairo")
does support it.
See X11
and the section on Cairo below.
The other workaround requires use of the gpclib package which
effects a triangulation of the polygonal window in question which
in turn permits the plotting of the window, filled with a solid
colour, without filling the holes. Type licence.polygons()
for information about the licence under which gpclib operates.
To make use of this workaround you need to have the packagegpclib
installed and to set spatstat.options(gpclib=TRUE)
(and to be
working under circumstances permitted by the gpclib licence).
Linux systems support
the graphics device X11(type="cairo")
(see X11
)
provided the external library cairo is installed
on the computer. See http://www.cairographics.org/download
for instructions on obtaining and installing cairo. After having
installed cairo one needs to re-install R from source so
that it has cairo capabilites. To check whether your
current installation of R has cairo capabilities, type
(in R) capabilities()["cairo"]
.
The default type for X11
is controlled by
X11.options
.
You may find it convenient to
make cairo the default, e.g. via your .Rprofile
.
The magic incantation to put into .Rprofile
is
setHook(packageEvent("graphics", "onLoad"), function(...) grDevices::X11.options(type="cairo"))
Adrian Baddeley Adrian.Baddeley@csiro.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner r.turner@auckland.ac.nz
owin.object
,
plot.ppp
,
polygon
,
image.default
,
spatstat.options
# rectangular window data(nztrees) plot(nztrees$window) abline(v=148, lty=2) # polygonal window data(demopat) w <- demopat$window plot(w) plot(w, col="red", border="green", lwd=2) plot(w, hatch=TRUE, lwd=2) # binary mask we <- as.mask(erosion(w, 400, FALSE)) plot(we) op <- spatstat.options(par.binary=list(col=grey(c(0.5,1)))) plot(we) spatstat.options(op)