pkg <- read.dcf(here::here("DESCRIPTION"), fields = "Package")[1]
description <- read.dcf(here::here("DESCRIPTION"), fields = "Description")[1]

# If you're using R<4.1.1, need this version of rvcheck
# devtools::install_version('rvcheck',version='0.1.8') 
library(hexSticker)
library(dplyr)
library(ggplot2)
library(ggimage)
# library(ggpattern)# remotes::install_github("coolbutuseless/ggpattern")

You can make awesome hex stickers for your R packages using:

r pkg

File path

Create file path to save hex sticker to.

filename <- here::here("inst/hex/hex.png")
dir.create(dirname(filename), showWarnings = FALSE, recursive = TRUE)

Subplot

Palette semi-automatically made with Peaky Blinders image and Image picker,

ggimage

library(ggridges)
peaky_palette <- c("#292D34",
                   "#3A3D4E",
                   "#4B4F52",
                   "#655D48",
                   "#868077",
                   "#B4966E",
                   "#B1A47F",
                   "#C8C5A6")
peaky_palette <- c(rev(peaky_palette),peaky_palette)

lvls <- c("July","June","August","September","May")
dat <- subset(lincoln_weather, Month %in% lvls) %>% 
    dplyr::mutate(value=`Mean Temperature [F]`)
center <- mean(subset(dat,Month=="July")$value)
dat$Month <- factor(x = dat$Month, levels = lvls, ordered = TRUE)
# dat <- rbind(
#     dat,
#     subset(dat, Month=="June") %>% dplyr::mutate(value=value+center)
# )

gp <- ggplot(dat, 
       aes(x = value, 
           y = Month, fill = stat(x))) +
  geom_density_ridges_gradient(scale = 3, 
                               rel_min_height = 0.01, 
                               show.legend = FALSE,
                               gradient_lwd = .5,
                               lwd=.2,
                               alpha=.8,
                               color="white") + 
      scale_fill_gradientn(colours = peaky_palette) + 
    theme_void() 
print(gp)

hexSticker

s_size = 1.25
stick <- hexSticker::sticker( 
  subplot = gp,
  #### Package name ####
  package = pkg, p_size=5, p_y = 1.5,
  #### Subplot #####
  s_x=1, s_y=.8,  s_height = s_size, s_width = s_size,
  #### Fill & border ####
  h_fill = "#3A3D4E", h_color = "#d6be88",
  #### Spotlight ####
  spotlight = TRUE, l_alpha = .3, l_width = 10, l_y = 1.3,
  #### File output ####
  filename = filename, dpi = 300)
print(stick)

Session Info

utils::sessionInfo()



neurogenomics/PeakyFinders documentation built on March 24, 2024, 4:28 p.m.