| reshape_ggplot | R Documentation |
Auto-wrap (and optionally resize the font of) the title, subtitle, caption
and axis labels of a ggplot2 plot using stringr::str_wrap(). Useful to tidy
up long titles produced automatically by other MiscMetabar plotting
functions, in particular before combining several plots with patchwork.
See also function resize_fonts from ggplotpq package.
reshape_ggplot(
plot,
width = 60,
width_subtitle = width * fontsize_title/fontsize_subtitle,
width_labs = width * fontsize_title/fontsize_labs,
width_caption = width * fontsize_title/fontsize_caption,
fontsize_title = 10,
fontsize_subtitle = 7,
fontsize_labs = 8,
fontsize_caption = 7
)
plot |
(required) A ggplot2 object. |
width |
(int, default 60) The wrapping width (in characters) of the title. Also used to compute the default value of the other widths. |
width_subtitle |
(int, default |
width_labs |
(int, default |
width_caption |
(int, default |
fontsize_title |
(int, default 10) Font size for the title. |
fontsize_subtitle |
(int, default 7) Font size for the subtitle. |
fontsize_labs |
(int, default 8) Font size for the x and y axis labels. |
fontsize_caption |
(int, default 7) Font size for the caption. |
A ggplot2 object with wrapped/resized text elements.
Adrien Taudière
if (requireNamespace("stringr") && requireNamespace("patchwork")) {
df_mini <- prune_samples(
sample_names(data_fungi_mini)[1:5],
data_fungi_mini
)
patchwork::wrap_plots(lapply(
hill_pq(df_mini, "Height", vioplot = TRUE),
reshape_ggplot,
width = 45
))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.