BoulderCodeHub / Process-CRSS-Res

Repository for code used to process CRSS Results starting in April 2015
1 stars 3 forks source link

add_logo() update #91

Closed cfelletter closed 4 years ago

cfelletter commented 5 years ago

here is what I'm using you might want to tweak it

add_logo_horiz <- function(gg)
{
  # arrange all 3 plots together
  gg_grob <- ggplotGrob(gg)

  # logo -------------------------------
  logo <- imager::load.image("code/logo/BofR-horiz-cmyk.png")
  logo <- grid::rasterGrob(logo, interpolate = TRUE)

  l2 <- ggplot() +
    geom_blank() + 
    theme_minimal() +
    annotation_custom(logo)

  gg <- grid.arrange(arrangeGrob(
    gg_grob, nullGrob(), l2,
    layout_matrix = matrix(c(1,1,2,3), ncol = 2, byrow = TRUE),
    heights = c(.9, .1),
    widths = c(.7, .3)
    #bottom = cap_text
  ))

  gg
}

add_logo_shield <- function(gg)
{
  # arrange all 3 plots together
  gg_grob <- ggplotGrob(gg)

  # logo -------------------------------
  # logo <- imager::load.image("code/logo/BofR-vert-cmyk.png")
  logo <- imager::load.image("code/logo/seal-white.png") #saved from the BOR page footer
  # logo <- imager::load.image("code/logo/BofR-shield-cmyk.png") #not as crisp 

  logo <- grid::rasterGrob(logo, interpolate = TRUE)

  l2 <- ggplot() +
    geom_blank() + 
    theme_minimal() +
    annotation_custom(logo)

  gg <- grid.arrange(arrangeGrob(
    gg_grob, nullGrob(), l2,
    layout_matrix = matrix(c(1,1,2,3), ncol = 2, byrow = TRUE),
    heights = c(.9, .1),
    widths = c(.9, .1)
    #bottom = cap_text
  ))

  gg
}