A clean ggplot2 theme for ecological publications: white background, minimal gridlines, suitable for journal figures.
theme_ecology <- function(base_size = 12) {
ggplot2::theme_bw(base_size = base_size) +
ggplot2::theme(
panel.grid.minor = ggplot2::element_blank(),
panel.grid.major = ggplot2::element_line(colour = "#f0f0f0", linewidth = 0.4),
panel.border = ggplot2::element_rect(colour = "#888888", linewidth = 0.6),
strip.background = ggplot2::element_rect(fill = "#f5f5f5", colour = "#888888"),
legend.background = ggplot2::element_blank(),
legend.key = ggplot2::element_blank(),
axis.ticks = ggplot2::element_line(linewidth = 0.4)
)
}
# Example
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Petal.Length, colour = Species)) +
geom_point(size = 2, alpha = 0.7) +
theme_ecology()
# ── Example ──────────────────────────────────────────────────────
library(ggplot2)
ggplot(iris, aes(Sepal.Length, Petal.Length, colour = Species)) +
geom_point(size = 2.5, alpha = 0.7) +
geom_smooth(method = "lm", se = FALSE, linewidth = 0.8) +
labs(title = "Sepal vs Petal length by species",
x = "Sepal length (cm)", y = "Petal length (cm)") +
theme_ecology(base_size = 12)