#' Create an Hexagonal Sticker for the Package
library("ggplot2")
library("dplyr")
data(aravo, package = "ade4")
scaled_traits = scale(aravo$traits)
species_pca = prcomp(scaled_traits)
trait_distance = dist(species_pca$x[,1:2])
global_di = funrar::distinctiveness_global(trait_distance)
species_traits_di = species_pca$x[,1:2] %>%
as.data.frame() %>%
tibble::rownames_to_column("species") %>%
inner_join(global_di, by = "species")
# Actual plot ------------------------------------------------------------------
p <- ggplot2::ggplot(
species_traits_di, aes(PC1, PC2, size = global_di, color = global_di)
) +
geom_hline(yintercept = 0, linewidth = 1/2, linetype = 2, color = "#94a3b7") +
geom_vline(xintercept = 0, linewidth = 1/2, linetype = 2, color = "#94a3b7") +
geom_point() +
colorspace::scale_color_continuous_sequential("plasma", rev = FALSE) +
scale_size_continuous(range = c(0.005, 2.3)) +
# coord_cartesian(clip = "off") +
ggplot2::theme_void() +
hexSticker::theme_transparent() +
theme(legend.position = "none")
p
# Sticker -----------------------------------------------------
hexSticker::sticker(
subplot = p,
package = "funrar",
filename = here::here("man", "figures", "logo.png"),
dpi = 300,
p_size = 22, # Title
u_size = 6, # URL
# p_family = "Aller_Rg",
p_color = "#222222", # Title
h_fill = "#CAE1FF", # Background
h_color = "#222222", # Border
u_color = "#222222", # URL
# p_x = 1.00, # Title
p_y = 1.65, # Title
s_x = 1.05, # Subplot
s_y = 0.9, # Subplot
s_width = 1.25, # Subplot
s_height = 1.25, # Subplot
url = "https://github.com/Rekyt/",
spotlight = FALSE,
l_alpha = 0.7,
l_width = 0.1,
l_height = 1.4,
l_y = 1.6
)
# Other background color '#94a3b7'
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.