Plot a two-dimensional line segment pattern
# S3 method for psp
plot(x, …, main, add=FALSE,
show.all=!add, show.window=show.all,
which.marks=1,
style=c("colour", "width", "none"),
col=NULL,
ribbon=show.all,
ribsep=0.15, ribwid=0.05, ribn=1024,
do.plot=TRUE)
The line segment pattern to be plotted.
An object of class "psp"
,
or data which can be converted into
this format by as.psp()
.
Character string giving a title for the plot.
Logical. If TRUE
, the current plot is not erased;
the segments are plotted on top of the
current plot, and the window is not plotted (by default).
Logical value specifying whether to plot everything including the window, main title, and colour ribbon.
Logical value specifying whether to plot the window.
Index determining which column of marks to use,
if the marks of x
are a data frame.
A character string or an integer.
Defaults to 1
indicating the first column of marks.
Character string specifying how to represent the
mark value of each segment. If style="colour"
(the default)
segments are coloured according to their mark value.
If style="width"
, segments are drawn with a width
proportional to their mark value.
If style="none"
the mark values are ignored.
Colour information.
If style="width"
or style="none"
,
then col
should be a single value,
interpretable as a colour; the line segments will be plotted
using this colour.
If style="colour"
and x
has marks,
then the mark values will be mapped
to colours using the information in col
, which should be a
colour map (object of class "colourmap"
)
or a vector of colour values.
Logical flag indicating whether to display a ribbon
showing the colour map (in which mark values are associated with
colours) when style="colour"
.
Factor controlling the space between the ribbon and the image.
Factor controlling the width of the ribbon.
Number of different values to display in the ribbon.
Logical value indicating whether to actually perform the plot.
(Invisibly) a colour map object specifying the association between
marks and colours, if any. The return value also has an attribute
"bbox"
giving a bounding box for the plot.
This is the plot
method for
line segment pattern datasets (of class "psp"
,
see psp.object
).
It plots both the observation window Window(x)
and the line segments themselves.
Plotting of the window Window(x)
is performed by
plot.owin
. This plot may be modified
through the ...
arguments.
Plotting of the segments themselves is performed
by the standard R function segments
.
Its plotting behaviour may also be modified through the ...
arguments.
If the segments do not have marks (i.e. if marks(x) = NULL
)
then
There are three different styles of plotting
which apply when the segments have marks
(i.e. when marks(x)
is not null):
style="colour"
(the default):Segments are plotted with different colours depending on their
mark values.
The colour map, associating mark values with colours,
is determined by the argument col
. The colour map will be
displayed as a vertical colour ribbon to the right of the plot, if
ribbon=TRUE
(the default).
style="width"
:Segments are plotted with different widths depending on their
mark values.
The width map, associating mark values with line widths,
is determined by leg.scale
(see plot.linim
).
The width map will be displayed as a vertical stack of lines
to the right of the plot, if legend=TRUE
(the default).
style="none"
:Mark information is ignored.
If marks(x)
is a data frame, the default is to use the first
column of marks(x)
to determine the colours. To specify another
column, use the argument which.marks
.
# NOT RUN {
X <- psp(runif(20), runif(20), runif(20), runif(20), window=owin())
plot(X)
plot(X, lwd=3)
lettuce <- sample(letters[1:4], 20, replace=TRUE)
marks(X) <- data.frame(A=1:20, B=factor(lettuce))
plot(X)
plot(X, which.marks="B")
plot(X, style="width", col="grey")
# }
Run the code above in your browser using DataLab