if (requireNamespace(
c("palmerpenguins", "tidyr", "ggplot2"),
quiet = TRUE
)
) {
library(ggplot2)
library(palmerpenguins)
library(tidyr)
penguins |>
drop_na(bill_length_mm, species) |>
ggplot(aes(x = species, y = bill_length_mm, fill = species)) +
geom_boxplot(outlier.color = get_brand_color("red")) +
geom_jitter(width = 0.2, alpha = 0.1) +
scale_fill_brand_d(alpha = 0.5) +
labs(
x = "Species",
y = "Bill Length (mm)",
fill = "Species"
) +
theme_bw()
}
if (requireNamespace(
c("palmerpenguins", "tidyr", "ggplot2"),
quiet = TRUE
)
) {
library(ggplot2)
library(palmerpenguins)
library(tidyr)
penguins |>
drop_na(flipper_length_mm, species) |>
ggplot(aes(x = flipper_length_mm, fill = species)) +
geom_histogram(alpha = 0.5, bins = 30, position = "identity") +
scale_fill_brand_d() +
labs(
x = "Flipper Length (mm)",
y = "Frequency",
fill = "Species"
) +
theme_bw()
}
if (requireNamespace(
c("palmerpenguins", "tidyr", "ggplot2"),
quiet = TRUE
)
) {
library(ggplot2)
library(palmerpenguins)
library(tidyr)
penguins |>
drop_na(flipper_length_mm, body_mass_g, species) |>
ggplot(
aes(
x = flipper_length_mm,
y = body_mass_g,
color = species,
shape = species
)
) +
geom_point(size = 2) +
geom_smooth(method = "lm", formula = y ~ x, se = FALSE) +
scale_color_brand_d() +
labs(
x = "Flipper Length (mm)",
y = "Body Mass (g)",
color = "Species",
shape = "Species"
) +
theme_bw()
}
if (requireNamespace("ggplot2", quiet = TRUE)) {
library(ggplot2)
faithfuld |>
ggplot(aes(waiting, eruptions, fill = density)) +
geom_raster() +
scale_fill_brand_b() +
labs(
x = "Waiting Time to Next Eruption (min)",
y = "Eruption Time (min)",
fill = "Density"
) +
theme_bw()
}
if (requireNamespace("ggplot2", quiet = TRUE)) {
library(ggplot2)
library(hexbin)
data.frame(x = runif(10000), y = runif(10000)) |>
ggplot(aes(x, y)) +
geom_hex() +
coord_fixed() +
scale_fill_brand_c() +
labs(fill = "") +
theme_bw()
}
Run the code above in your browser using DataLab