View source: R/finalise_plot.R
pretty_plot | R Documentation |
pretty_plot
is a wrapper to place a logo at the bottom right and an optional text at the bottom left.
It is intended to give a consistent, 'corporate' feel to figures.
It adds an extra margin to the plot at the bottom where the logos and text are placed.
pretty_plot( plot, source_name = "", logo_path, text_size = 16, theme_apply = TRUE, facet_apply = FALSE )
plot |
A |
source_name |
A character string of text to be added bottom left. |
logo_path |
Filepath to png or jpg file of logo to be added bottom right. |
text_size |
Font size for the text. Default is 16 |
theme_apply |
Logical. If |
facet_apply |
Logical. If |
A plot with text (left) and logo (right)
library(ggplot2) pl_1 <- ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point() pl_1_no_legend <- ggplot(mpg, aes(displ, hwy, colour = class)) + geom_point(show.legend = FALSE) pl_1 pl_1_no_legend pp_pl_1 <- pretty_plot(pl_1, source = "Text 14 point", logo_path = system.file("extdata", "SNAP3_2019.jpg", package = "testpackage"), text_size = 14, theme_apply = FALSE) pp_pl_1 pp_pl_1_no_legend <- pretty_plot(pl_1, source = "Text 16 point, HSRC theme", logo_path = system.file("extdata", "SNAP3_2019.jpg", package = "testpackage"), text_size = 16, theme_apply = TRUE) pp_pl_1_no_legend pl_2 <- ggplot(mpg, aes(displ, hwy)) + geom_point() + facet_wrap(~class, ncol = 3) pp_pl_2 <- pretty_plot(pl_2, source_name = "Facet wrap",logo_path = system.file("extdata", "SNAP3_2019.jpg", package = "testpackage"), text_size = 16, theme_apply = TRUE, facet_apply = TRUE) pp_pl_2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.