knitr::opts_chunk$set(echo = TRUE, fig.width = 7, fig.height = 5, root.dir=here::here()) knitr::opts_knit$set(root.dir=here::here())
You can make awesome hex stickers for your R packages using hexSticker.
Silhouettes from phylopic.
ggimage let's you render images as data points.
ggpattern lets you fill objects with patterns or images.
library(hexSticker) library(dplyr) library(ggplot2) library(ggimage) library(ggpattern)# remotes::install_github("coolbutuseless/ggpattern") library(ggplot2) pBase <- "http://phylopic.org/assets/images/submissions" image_info <- data.frame( image = file.path(pBase, c("c089caae-43ef-4e4e-bf26-973dd4cb65c5.512.png",# Human "eedde61f-3402-4f7c-9350-49b74f5e1dba.512.png", # Macaque "c8f71c27-71db-4b34-ac2d-e97fea8762cf.original.png", # Mouse "6f4c653a-1da1-4e02-85ef-6344b2d8e02a.512.png", # Zebrafish "ea8fa530-d856-4423-a81d-a74342cd1875.512.png", # Fly "d6af4346-e56c-4f3d-84c7-fba921a293f1.512.png" # Worm ) ), species = c("Human", "Macaque", "Mouse", "Zebrafish", "Fly","Worm" ), size=c(.5,1,1.1, 1.1,1.1,1)/5, alpha=c(.8,.8,1, .8,.8,1) ) image_info <- rbind(image_info, image_info[1,] |> dplyr::mutate(size=0)) ### From ggimage code polygon_df <- dplyr::tibble( angle = seq(0, 2*pi, length.out = 7) + pi/6, x = cos(angle), y = sin(angle) ) polygon_df2 <- dplyr::tibble( angle = seq(0, 2*pi, length.out = 7) + pi/6, x = cos(angle)*1.25, y = sin(angle)*1.25 ) d <- cbind(polygon_df, image_info) hex_species <- ggplot(d, aes(x, y)) + ggpattern::geom_polygon_pattern(data = polygon_df2, pattern= 'image', aes(x=I(x/1), y=I(y/1)), pattern_type = 'expand', pattern_filename = here::here("inst/images/purple_blue.jpeg"), inherit.aes = FALSE) + geom_path(color="white", size = .8, alpha=.1) + geom_path(color="white", size=.5, alpha=.5) + geom_path(color="white", size=.1, alpha=1) + # geom_image(aes(image=image), size=.12, color="white", alpha=.1) + # geom_image(aes(image=image), size=.11, color="white", alpha=.2) + geom_image(aes(image=image, x=I(x/1), y=I(y/1), size=I(size), alpha=I(alpha)), color="white") + theme_void() s_width <- 1.6 s <- sticker(hex_species, package="orthogene", p_size=20, p_y = 1, s_x=1, s_y=1, s_width=s_width, s_height=s_width*1.11111, h_color = "black", h_fill = "#330862",white_around_sticker = TRUE, filename=here::here("inst/hex/hex.png"), dpi = 400) print(s)
utils::sessionInfo()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.