Skip to contents

Overview

In order to add a logo you should create your plot, save it, and then use add_logo(). The function takes on six arguments:

  • plot_path: url or local file for the plot

  • logo_path: url, local file for the plot or one of the built in logos.

  • logo_position: Optional argument. Can be ‘top left’, ‘top right’, ‘bottom left’, and ‘bottom right’. As per the Brookings style guide, the default logo position is ‘bottom right’.

  • logo_scale: Optional argument. The portion of the plot width the logo should occupy. The default is 5 which means that the logo will be 1/5th of the plot width.

  • height_padding: Optional argument. Control the y axis position of a logo by specifying the padding proportion. Default is 4.5% padding.

  • width_padding: Optional argument. Control the x axis position of a logo by specifying the padding proportion. Default is 1% padding.

Currently, the available built in logos are:

Program/Center Abbreviation
Brookings ‘brookings’
Economic Studies ‘es’
Government Studies ‘gs’
Foreign Policy ‘fp’
Metro ‘metro’
Global ‘global’
Bass Initiative ‘bi’
Brown Center ‘bc’
China Center ‘cc’
Center for Children and Families ‘ccf’
Center for East Asia Policy Studies ‘ceaps’
Center for Effective Public Management ‘cepm’
Center for Health Policy ‘chp’
Center for Middle East Policy ‘cmep’
Center for Sustainable Development ‘csd’
Center for Technology Innovation ‘cti’
Center for Universal Education ‘cue’
Center on United States and Europe ‘cuse’
Center on Regulation and Markets ‘crm’
Hutchins Center ‘hc’

For more information on how this function works, please read Tom Mock’s fantastic blog post on how to add a logo to your plot. ggbrookings::add_logo() builds off of the function described in the article with some minor modifications.

Example

We start by creating a plot and using ggsave() to save it.

librarian::shelf(ggplot2, ggbrookings, palmerpenguins, magick)
theme_set(theme_brookings())

p1 <-
  ggplot(data = penguins, aes(x = flipper_length_mm)) +
  geom_histogram(aes(fill = species),
                 alpha = 0.5,
                 position = "identity",
                 bins = 30) +
  scale_fill_brookings(palette = "semantic3") +
  labs(x = "Flipper length (mm)",
       y = "Frequency",
       title = "Penguin flipper lengths",
       caption = '**Source:** Palmer Penguins',
       tag = 'FIGURE 1') +
  scale_x_continuous(expand = expansion()) +
  scale_y_continuous(expand = expansion())

ggsave("penguins.png", p1, dpi=300, height=3.7, width=6, units="in")

Finally, to add a logo call:

add_logo('penguins.png', logo_path = 'brookings', 'bottom right', 5)

The image will show up in your Viewer pane. To save it as a png you can right click on it and select “Save Image As…” or, more reproducibly, assign it to an object and then call magick::image_write() as below:

penguins_plot <- add_logo('penguins.png', logo_path = 'brookings', 'bottom right', 5)

image_write(penguins_plot, "penguins.png")