textbox_grob: A simple grob for the word cloud

View source: R/anno_textbox.R

textbox_grobR Documentation

A simple grob for the word cloud

Description

A simple grob for the word cloud

Usage

textbox_grob(text, x = unit(0.5, "npc"), y = unit(0.5, "npc"), just = "centre",
    gp = gpar(), background_gp = gpar(col = "black", fill = "transparent"), round_corners = FALSE, r = unit(0.1, "snpc"),
    line_space = unit(4, "pt"), text_space = unit(4, "pt"), max_width = unit(100, "mm"),
    padding = unit(4, "pt"), first_text_from = "top", add_new_line = FALSE, word_wrap = FALSE)

Arguments

text

A vector of texts. The value can be single words or phrases/sentenses.

x

X position.

y

Y position.

just

Justification of the box in the viewport.

gp

Graphics parameters of texts.

background_gp

Graphics parameters for the box.

round_corners

Whether to draw round corners for the box.

r

Radius of the round corners.

line_space

Space between lines. The value can be a unit object or a numeric scalar which is measured in mm.

text_space

Space between texts The value can be a unit object or a numeric scalar which is measured in mm.

max_width

The maximal width of the viewport to put the word cloud. The value can be a unit object or a numeric scalar which is measured in mm. Note this might be larger than the final width of the returned grob object.

padding

Padding of the box, i.e. space between text and the four box borders. The value should be a unit object with length 1, 2 or 4. If length of the input unit is 2, the first value is the padding both to the top and to the bottom, and the second value is the padding to the left and right. If length of the input unit is 4, the four values correspond to paddings to the bottom, left, top and right of the box.

first_text_from

Should the texts be added from the top of the box or from the bottom? Value should be either "top" or "bottom".

add_new_line

Whether to add new line after every text? If TRUE, each text will be in a separated line.

word_wrap

Whether to apply word wrap for phrases/sentenses.

Value

A grob object. The width and height of the grob can be get by grobWidth and grobHeight.

Examples

words = sapply(1:30, function(x) strrep(sample(letters, 1), sample(3:10, 1)))
grid.newpage()
grid.textbox(words, gp = gpar(fontsize = runif(30, min = 5, max = 30)))

sentenses = c("This is sentense 1", "This is a long long long long long long long sentense.")
grid.newpage()
grid.textbox(sentenses)
grid.textbox(sentenses, word_wrap = TRUE)
grid.textbox(sentenses, word_wrap = TRUE, add_new_line = TRUE)

jokergoo/ComplexHeatmap documentation built on Dec. 22, 2024, 8:51 a.m.