font | R Documentation |
Change the appearance of the main title, subtitle, caption, axis
labels and text, as well as the legend title and texts. Wrapper around
element_text()
.
font(object, size = NULL, color = NULL, face = NULL, family = NULL, ...)
object |
character string specifying the plot components. Allowed values include:
|
size |
numeric value specifying the font size, (e.g.: |
color |
character string specifying the font color, (e.g.: |
face |
the font face or style. Allowed values include one of
|
family |
the font family. |
... |
other arguments to pass to the function
|
# Load data data("ToothGrowth") # Basic plot p <- ggboxplot(ToothGrowth, x = "dose", y = "len", color = "dose", title = "Box Plot created with ggpubr", subtitle = "Length by dose", caption = "Source: ggpubr", xlab ="Dose (mg)", ylab = "Teeth length") p # Change the appearance of titles and labels p + font("title", size = 14, color = "red", face = "bold.italic")+ font("subtitle", size = 10, color = "orange")+ font("caption", size = 10, color = "orange")+ font("xlab", size = 12, color = "blue")+ font("ylab", size = 12, color = "#993333")+ font("xy.text", size = 12, color = "gray", face = "bold") # Change the appearance of legend title and texts p + font("legend.title", color = "blue", face = "bold")+ font("legend.text", color = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.