textbox_grob | R Documentation |
A simple grob for the word cloud
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)
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 |
text_space |
Space between texts The value can be a |
max_width |
The maximal width of the viewport to put the word cloud. The value can be a |
padding |
Padding of the box, i.e. space between text and the four box borders. The value should be a |
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 |
word_wrap |
Whether to apply word wrap for phrases/sentenses. |
A grob
object. The width and height of the grob can be get by grobWidth
and grobHeight
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.