add.layout | R Documentation |
add.layout
creates or adds to a layout of non-overlapping
rectangles.
add.labels
is a front-end to add.layout
which creates a
layout suitable for labels allowing to adjust the placement of the label
with respect to the original points and to add extra margins.
add.layout(x, y, w, h, rs = 0.01, as = 0.22, ri = 0, ai = 0, l = NULL) add.labels(x, y, txt, w, h, adj = 0.5, mar = 0.1, ...)
x |
x coordinates of the points to add. For rectangles it is the left edge. |
y |
y coordinates of the points to add. For rectangles it is the bottom edge. |
w |
width of the rectangles (optional for labels where it defaults to the label widths) |
h |
height of the rectangles (optional for labels where it defaults to the label height) |
rs |
radius step for the placement algorithm |
as |
angle step for the placement algorithm |
ri |
initial radius for the placement algorithm |
ai |
initial angle for the placement algorithm |
l |
layout to add to or |
txt |
text labels to add |
adj |
adjustment of the text position with respect to the
supplied points (see |
mar |
additional margins around the text (relative to the width or height). If present, it will be recycled to length two for horizontal and vertical margins respectively. |
... |
additional parameters passed through to |
The layout attempts to sequentially place rectangles of the given width and height at the specified points. If a placement of a new rectangle would overlap with any existing rectangle, it is moved until it no longer overlaps. The current algorithm defines the movement as a clockwise spiral.
add.layout
returns an obejct of the class box.layout
which consists of a list with elements x
, y
, w
and h
. If the input was non-overlapping it would be equivalent
to the (recycled) arguments. If there are overlaps the x
and
y
coordinates will differ accordingly.
If l
is specified on input, it is expected to be
box.layout
as well and the layout is extended by adding the
rectangles defined in the arguments.
add.labels
returns an object of the class label.layout
which is a subclass of box.layout
. It adds the components
lx
and ly
which are the label coordinates (as opposed to
the rectangle coordinates). If adj
is zero the label and box
coordinates are equal.
x = rnorm(100) y = rnorm(100) txt = sprintf("%.2f", rnorm(100)) plot(x, y, pch=3, col=2) l = add.labels(x, y, txt, mar=0.2) rect(l$x, l$y, l$x + l$w, l$y + l$h, col="#00000020", border=NA) text(l$lx, l$ly, txt, col=4) segments(x, y, l$lx, l$ly, col=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.