This article provides examples of how the add_logo()
function can be used.
First, we’ll make an example plot to add our logos to using the mtcars
dataset. Let’s see how quarter-mile time, qsec
, varies with horsepower, hp
:
test_plot <- mtcars %>%
ggplot(aes(hp, qsec)) +
geom_point() +
geom_smooth() +
scale_x_continuous("Horsepower") +
scale_y_continuous("Quarter\nMile\nTime") +
theme_minimal() +
theme(axis.title.y = element_text(angle = 0, vjust = 0.5))
test_plot
Running the following code will save an image with the Microsoft logo in the "viz/"
folder in the user’s project directory.
add_logo(plot = test_plot,
logo = "microsoft",
caption = "This is a test.",
filename = "test_microsoft.png",
path = "viz/")
It would look like this:
Running the following code will save an image with the PMI logo in the "viz/"
folder in the user’s project directory.
add_logo(plot = test_plot,
logo = "pmi",
caption = "This is a test.",
filename = "test_pmi.png",
path = "viz/")
It would look like this:
We can easily add new logos by including them as a .png file in the logos
folder in the GitHub repo.
If the file that was added was “new_logo.png”, then to use this logo provide logo = "new_logo"
as an argument to the add_logo
function.