# plot.owin

0th

Percentile

##### Plot a Spatial Window

Plot a two-dimensional window of observation for a spatial point pattern

Keywords
hplot, spatial
##### Usage
# S3 method for owin
plot(x, main, add=FALSE, …, box, edge=0.04,
hatch=FALSE,
hatchargs=list(),
invert=FALSE, do.plot=TRUE,
claim.title.space=FALSE)
##### Arguments
x

The window to be plotted. An object of class owin, or data which can be converted into this format by as.owin().

main

text to be displayed as a title above the plot.

logical flag: if TRUE, draw the window in the current plot; if FALSE, generate a new plot.

extra arguments controlling the appearance of the plot. These arguments are passed to polygon if x is a polygonal or rectangular window, or passed to image.default if x is a binary mask. See Details.

box

logical flag; if TRUE, plot the enclosing rectangular box

edge

nonnegative number; the plotting region will have coordinate limits that are 1 + edge times as large as the limits of the rectangular box that encloses the pattern.

type

Type of plot: either "w" or "n". If type="w" (the default), the window is plotted. If type="n" and add=TRUE, a new plot is initialised and the coordinate system is established, but nothing is drawn.

show.all

Logical value indicating whether to plot everything including the main title.

hatch

logical flag; if TRUE, the interior of the window will be shaded by texture, such as a grid of parallel lines.

hatchargs

List of arguments passed to add.texture to control the texture shading when hatch=TRUE.

invert

logical flag; when the window is a binary pixel mask, the mask colours will be inverted if invert=TRUE.

do.plot

Logical value indicating whether to actually perform the plot.

claim.title.space

Logical value indicating whether extra space for the main title should be allocated when declaring the plot dimensions. Should be set to FALSE under normal conditions.

##### Details

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.

##### Notes on Filled Polygons with Holes

The function polygon can only handle polygons without holes. To plot polygons with holes in a solid colour, we have implemented two workarounds.

polypath function:

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

polygon decomposition:

The other workaround involves decomposing the polygonal window into pieces which do not have holes. This code is experimental but works in all our test cases. If this code fails, a warning will be issued, and the filled colours will not be plotted.

##### Cairo graphics on a Linux system

Linux systems support the graphics device X11(type="cairo") (see X11) provided the external library cairo is installed on the computer. See www.cairographics.org 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"))


owin.object, plot.ppp, polygon, image.default, spatstat.options

• plot.owin
##### Examples
# NOT RUN {
# rectangular window
plot(Window(nztrees))
abline(v=148, lty=2)

# polygonal window
w <- Window(demopat)
plot(w)
plot(w, col="red", border="green", lwd=2)
plot(w, hatch=TRUE, lwd=2)