引言
分享一个刚发布不久的配色 R 包 poisonfrogs(毒蛙):顾名思义,它的灵感来源于一系列受 新热带毒蛙 启发的色彩调色板。超过 200 种色彩鲜艳的物种,新热带毒蛙用生动的色调为雨林着色,传递着清晰的信号:“我有毒!”。用 poisonfrogs 为你的图表增添色彩,给你的数据可视化带来毒性风格!
github:https://github.com/laurenoconnelllab/poisonfrogs/
安装
install.packages(“poisonfrogs”)
remotes::install_github(“laurenoconnelllab/poisonfrogs”)
library(poisonfrogs)
可用的配色示例展示
感觉这些蛙蛙有些也挺可爱的!
ggplot 使用示例
require(tidyverse)
require(gapminder)
require(ggridges)
require(scales)
require(patchwork)
continuous scale
df_nottem <- tibble(
year = floor(time(nottem)),
month = factor(month.abb[cycle(nottem)], levels = month.abb),
temp = as.numeric(nottem)
)
p1 <- ggplot(df_nottem, aes(x = temp, y = month, fill = after_stat(x))) +
geom_density_ridges_gradient(scale = 2, rel_min_height = 0.01) +
scale_fill_poison(
name = “Oskoi”,
type = “continuous”,
alpha = 0.95,
direction = -1) +
labs(
fill = “ºF”,
y = NULL,
x = NULL) +
theme_classic(base_size = 10, base_line_size = 0.5) +
theme(legend.position = “right”, legend.justification = “left”,
legend.margin = margin(0,0,0,0),
legend.box.margin = margin(-5,-5,-5,-5)) +
coord_cartesian(clip = “off”)
discrete scale
p2 <- ggplot(gapminder, aes(x = continent, y = lifeExp, fill = continent)) +
geom_boxplot(outliers = F) +
geom_jitter(
shape = 21,
position = position_jitter(0.1),
alpha = 0.2,
size = 0.8,
bg = “grey”
) +
stat_summary(
fun = mean,
geom = “point”,
size = 1.5,
color = “black”,
alpha = 0.6
) +
#theme_classic(base_size = 20, base_line_size = 0.5) +
scale_fill_poison(
name = “Amacero”,
type = “discrete”,
alpha = 0.9,
direction = 1
) +
theme(legend.position = “none”) +
xlab(NULL) +
ylab(“Life Expentancy”)
p1 + p2
Continuous scale
set.seed(42)
n <- 300
x <- runif(n, 0, 10)
y <- 1.5 + 0.9 * x + rnorm(n, sd = 0.4 + 0.25 * x)
sz <- rescale(y, to = c(2, 14))
df <- data.frame(x, y, sz)
p3 <- ggplot(df, aes(x, y)) +
geom_point(
aes(color = y, size = sz),
shape = 16,
alpha = 0.95,
stroke = 0.6
) +
scale_size_identity(guide = “none”) +
scale_color_poison(“Ramazonica”, type = “continuous”, direction = 1) +
theme_minimal() +
ylim(0, 18) +
xlim(0, 11)
discrete scale
p4 <- ggplot(gapminder, aes(x = lifeExp, y = log(gdpPercap), colour = continent)) +
geom_point(alpha = 0.4) +
scale_colour_poison(name = “Opcolon”, type = “discrete”) +
stat_smooth() +
facet_wrap(.~continent, scales = “free”) +
theme_minimal(10, base_line_size = 0.2) +
theme(legend.position = “none”,
strip.background = element_blank(), strip.placement = “outside”)
p3 + p4
结尾
路漫漫其修远兮,吾将上下而求索。
欢迎加入生信交流群。加我微信我也拉你进 微信群聊老俊俊生信交流群(微信交流群需收取 20 元入群费用,一旦交费,拒不退还!(防止骗子和便于管理)) 。
声明:来自老俊俊的生信笔记,仅代表创作者观点。链接:https://eyangzhen.com/4159.html