plot.im {spatstat} | R Documentation |
Plot a pixel image.
## S3 method for class 'im' plot(x, ..., col=NULL, valuesAreColours=NULL, ribbon=TRUE, ribsep=0.15, ribwid=0.05, ribn=1024, ribscale=1, ribargs=list())
x |
The pixel image to be plotted.
An object of class |
... |
Extra arguments passed to |
col |
Colours for displaying the pixel values.
Either a character vector of colour values,
or an object of class |
valuesAreColours |
Logical value. If |
ribbon |
Logical flag indicating whether to display a ribbon showing the colour map. |
ribsep |
Factor controlling the space between the ribbon and the image. |
ribwid |
Factor controlling the width of the ribbon. |
ribn |
Number of different values to display in the ribbon. |
ribscale |
Rescaling factor for tick marks. The values on the numerical scale printed beside the ribbon will be multiplied by this rescaling factor. |
ribargs |
List of additional arguments passed to
|
This is the plot
method for the class "im"
.
[It is also the image
method for "im"
.]
The pixel image x
is displayed on the current plot device,
using equal scales on the x
and y
axes.
If ribbon=TRUE
, a legend will be plotted at the right of the
image. The legend consists of a colour ribbon and an axis with tick-marks,
showing the correspondence between the pixel values and the colour map.
Arguments ribsep, ribwid, ribn
control the appearance of the
ribbon.
The width of the ribbon is ribwid
times the size of the pixel
image, where ‘size’ means the larger of the width and the height.
The distance separating the ribbon and the image is ribsep
times
the size of the pixel image. The ribbon contains ribn
different numerical values, evenly spaced between the minimum and
maximum pixel values in the image x
, rendered according to
the chosen colour map.
Arguments ribscale, ribargs
control the annotation of the
colour ribbon. To plot the colour ribbon without the axis and
tick-marks, use ribargs=list(axes=FALSE)
.
Normally the pixel values are displayed using the colours given in the
argument col
. This may be either an explicit colour map
(an object of class "colourmap"
, created by the function
colourmap
) or a character vector or integer vector
that specifies a set of colours.
If col
is an explicit colour map
(an object of class "colourmap"
) then the same colour
always represents the same numeric value. For example this ensures
that when we plot different images, the colour maps are consistent.
If col
is a character vector or integer vector that specifies
colours, then the colour mapping will be stretched to match the range of
pixel values in the image x
. In this case, the mapping of pixel values
to colours is determined as follows.
the values FALSE
and
TRUE
are mapped to the colours col[1]
and
col[2]
respectively.
The vector col
should have length 2.
the factor levels levels(x)
are mapped to the entries of col
in order. The vector
col
should have the same length as levels(x)
.
By default, the range of pixel values in x
is divided into n = length(col)
equal subintervals, which are mapped to the colours in col
.
(If col
was not specified, it defaults to a vector of 255
colours.)
Alternatively if the argument zlim
is given, it should be
a vector of length 2 specifying an interval of real numbers.
This interval will be used instead of the range of pixel
values. The interval from zlim[1]
to zlim[2]
will be
mapped to the colours in col
. This facility enables the user to
plot several images using a consistent colour map.
Alternatively if the argument breaks
is given, then this specifies
the endpoints of the subintervals that are mapped to each colour.
This is incompatible with zlim
.
The arguments col
and zlim
or breaks
are passed to the function image.default
.
For examples of the use of these arguments,
see image.default
.
Other graphical parameters controlling the display of both the pixel image
and the ribbon can be passed through the ...
arguments
to the function image.default
.
A parameter is handled only if it is one of the following:
a formal argument of image.default
that is operative when add=TRUE
.
one of the
parameters "main", "asp", "sub", "axes", "ann",
"cex", "font", "cex.axis", "cex.lab", "cex.main", "cex.sub",
"col.axis", "col.lab", "col.main", "col.sub",
"font.axis", "font.lab", "font.main", "font.sub"
described in par
.
the argument box
, a logical value specifying whether
a box should be drawn.
By default, images are plotted using image rasters rather than
polygons, by setting useRaster=TRUE
in image.default
.
Alternatively, the pixel values could be directly interpretable as colour values in R. That is, the pixel values could be character strings that represent colours, or values of a factor whose levels are character strings representing colours.
If valuesAreColours=TRUE
, then the pixel values will
be interpreted as colour values and displayed using these colours.
If valuesAreColours=FALSE
, then the pixel values will
not be interpreted as colour values, even if they could be.
If valuesAreColours=NULL
, the algorithm will guess
what it should do. If the argument col
is given,
the pixel values will not be interpreted as colour values. Otherwise,
if all the pixel values are strings that represent colours, then
they will be interpreted and displayed as colours.
If pixel values are interpreted as colours,
the arguments col
and ribbon
will be ignored,
and a ribbon will not be plotted.
none.
The help for image.default
explains that
errors may occur, or images may be rendered incorrectly, on some
devices, depending on the availability of colours and other
device-specific constraints.
An error may occur on some graphics devices if the image is very
large. If this happens, try setting useRaster=FALSE
in the
call to plot.im
.
Adrian Baddeley Adrian.Baddeley@csiro.au http://www.maths.uwa.edu.au/~adrian/ and Rolf Turner r.turner@auckland.ac.nz
im.object
,
colourmap
,
contour.im
,
persp.im
,
image.default
,
spatstat.options
# an image Z <- setcov(owin()) plot(Z) # stretchable colour map plot(Z, col=terrain.colors(128), axes=FALSE) # fixed colour map tc <- colourmap(rainbow(128), breaks=seq(-1,2,length=129)) plot(Z, col=tc) # tweaking the plot plot(Z, main="La vie en bleu", col.main="blue", cex.main=1.5, box=FALSE, ribargs=list(col.axis="blue", col.ticks="blue", cex.axis=0.75))