require(ggplot2)
require(gapminder)
require(ggridges)
require(tibble)
require(scales)
# Using `scale_color_poison()` with discrete scale
ggplot(gapminder, aes(x = lifeExp, y = log(gdpPercap), colour = continent)) +
geom_point(alpha = 0.2) +
scale_color_poison(name = "Ramazonica", type = "discrete") +
stat_smooth() +
facet_wrap(. ~ continent, scales = "free") +
theme_minimal(21, base_line_size = 0.2) +
theme(
legend.position = "none",
strip.background = element_blank(),
strip.placement = "outside"
)
# Using `scale_color_poison()` with continuous scale
ggplot(mtcars, aes(wt, mpg, colour = disp)) +
geom_point(size = 3) +
scale_color_poison("Ramazonica", type = "continuous", direction = -1) +
stat_smooth(col = "black") +
theme_classic(base_size = 32, base_line_size = 0.5)
# Using `scale_fill_poison()` with discrete scale
ggplot(gapminder, aes(x = continent, y = lifeExp, fill = continent)) +
geom_violin(trim = FALSE, alpha = 0.75) +
geom_jitter(
shape = 21,
position = position_jitter(0.1),
alpha = 0.3,
size = 0.8,
bg = "grey"
) +
stat_summary(
fun = mean,
geom = "point",
size = 1.5,
color = "black",
alpha = 0.6
) +
theme_classic(base_size = 32, base_line_size = 0.5) +
scale_fill_poison(
name = "Ramazonica",
type = "discrete",
alpha = 0.95,
direction = -1
) +
theme(legend.position = "none") +
xlab(NULL)
df_nottem <- tibble(year = floor(time(nottem)),
month = factor(month.abb[cycle(nottem)],
levels = month.abb),
temp = as.numeric(nottem))
# Using `scale_fill_poison()` with continuous scale
ggplot(df_nottem, aes(x = temp, y = month, fill = stat(x))) +
geom_density_ridges_gradient(scale = 2, rel_min_height = 0.01) +
scale_fill_poison(
name = "Ramazonica",
type = "continuous",
alpha = 0.95,
direction = 1
) +
labs(
fill = "ºF") +
theme_light(base_size = 26, base_line_size = 0.5) +
theme(
legend.position = "right",
legend.justification = "left",
legend.margin = margin(0,0,0,0),
legend.box.margin = margin(-20,-20,-20,-20)
)
Run the code above in your browser using DataLab