labeling_cells(labels = TRUE, varnames = TRUE, abbreviate_labels = FALSE, abbreviate_varnames = FALSE, gp_text = gpar(), lsep = ": ", lcollapse = "\n", just = "center", pos = "center", rot = 0, margin = unit(0.5, "lines"), clip_cells = TRUE, text = NULL, ...)
labeling_list(gp_text = gpar(), just = "left", pos = "left", lsep = ": ", sep = " ", offset = unit(c(2, 2), "lines"), varnames = TRUE, cols = 2, ...)
TRUE
means 1 character, FALSE
causes no abbreviation.
Values are recycled as needed.TRUE
means 1 character, FALSE
causes no abbreviation.
Values are recycled as needed."gpar"
used for the text drawn.labeling_list
)."unit"
of length 2 specifying the
offset in x- and y-direction of the text block drawn under the
strucplot (only used for labeling_list
).labeling_list
).labeling_cells
.)labeling_list
)
or at most 2 (labeling_cells
) specifying the labels'
horizontal position and justification (horizontal and vertical for
labeling_cells
).labeling_cells
)."unit"
(a numeric value is
converted to "lines"
) specifying an offset from the cell
borders (only used for labeling_cells
).labeling_cells
).NA
entries are not drawn.
This allows custom cell annotations (see examples).
Only used for labeling_cells
.strucplot
which then generates and calls
the labeling function. They assume that a strucplot has been drawn
and the corresponding viewport structure is pushed, so that by
navigating through the viewport tree the labels can be positioned
appropriately.
This help page only documents labeling_list
and
labeling_cells
; more functions are described on the help page
for labeling_border
.
The functions can also be used stand-alone as shown in the
examples. Using labeling_list
will typically necessitate a bottom margin
adjustment.
vignette("strucplot")
.
labeling_border
,
structable
,
grid.text
data("Titanic")
mosaic(Titanic, labeling = labeling_cells)
mosaic(Titanic, labeling = labeling_list)
## A more complex example, adding the observed frequencies
## to a mosaic plot:
tab <- ifelse(Titanic < 6, NA, Titanic)
mosaic(Titanic, pop = FALSE)
labeling_cells(text = tab, margin = 0)(Titanic)
Run the code above in your browser using DataLab