Description Usage Arguments Author(s) See Also Examples
View source: R/annotate_figure.R
Annotate figures including: i) ggplots, ii) arranged ggplots from
ggarrange()
, grid.arrange()
and
plot_grid()
.
1 2 3 |
p |
(arranged) ggplots. |
top, bottom, left, right |
optional string, or grob. |
fig.lab |
figure label (e.g.: "Figure 1"). |
fig.lab.pos |
position of the figure label, can be one of "top.left", "top", "top.right", "bottom.left", "bottom", "bottom.right". Default is "top.left". |
fig.lab.size |
optional size of the figure label. |
fig.lab.face |
optional font face of the figure label. Allowed values include: "plain", "bold", "italic", "bold.italic". |
Alboukadel Kassambara alboukadel.kassambara@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | data("ToothGrowth")
df <- ToothGrowth
df$dose <- as.factor(df$dose)
# Create some plots
# ::::::::::::::::::::::::::::::::::::::::::::::::::
# Box plot
bxp <- ggboxplot(df, x = "dose", y = "len",
color = "dose", palette = "jco")
# Dot plot
dp <- ggdotplot(df, x = "dose", y = "len",
color = "dose", palette = "jco")
# Density plot
dens <- ggdensity(df, x = "len", fill = "dose", palette = "jco")
# Arrange and annotate
# ::::::::::::::::::::::::::::::::::::::::::::::::::
figure <- ggarrange(bxp, dp, dens, ncol = 2, nrow = 2)
annotate_figure(figure,
top = text_grob("Visualizing Tooth Growth", color = "red", face = "bold", size = 14),
bottom = text_grob("Data source: \n ToothGrowth data set", color = "blue",
hjust = 1, x = 1, face = "italic", size = 10),
left = text_grob("Figure arranged using ggpubr", color = "green", rot = 90),
right = "I'm done, thanks :-)!",
fig.lab = "Figure 1", fig.lab.face = "bold"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.