skills/r-plotting-style/SKILL.md
R ggplot2 plotting conventions and theme. Use when creating, modifying, or styling ggplot2 plots in R, or when adjusting plot themes, colors, labels, or formatting.
npx skillsauth add musserlab/lab-claude-skills r-plotting-styleInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Always use theme_classic() as the base for plots. This provides a clean, minimal style without grid lines.
# Standard theme_clean function for all projects
theme_clean <- function(base_size = 12) {
theme_classic(base_size = base_size) +
theme(
plot.title = element_text(face = "bold", size = base_size * 1.1),
plot.subtitle = element_text(size = base_size * 0.9, color = "grey40"),
plot.title.position = "plot",
plot.caption.position = "plot",
plot.margin = margin(12, 12, 12, 12),
axis.line = element_line(linewidth = 0.4, color = "grey30"),
axis.ticks = element_line(linewidth = 0.3, color = "grey30"),
axis.text = element_text(size = base_size * 0.9, color = "grey20"),
axis.title = element_text(size = base_size, color = "grey20"),
legend.title = element_text(size = base_size * 0.9),
legend.text = element_text(size = base_size * 0.85),
strip.text = element_text(face = "bold", size = base_size),
strip.background = element_blank()
)
}
theme_classic() not theme_bw()Ensure text never overlaps or falls off the plot edge:
ggrepel for data labels — geom_text_repel() and geom_label_repel() prevent overlapaxis.text.x = element_text(angle = 45, hjust = 1)plot.margin if labels are clippedstr_wrap() for titles or labels exceeding plot width# Example: repel labels to avoid overlap
library(ggrepel)
ggplot(data, aes(x, y, label = gene)) +
geom_point() +
geom_text_repel(max.overlaps = 20, size = 3)
When creating multiple plots of the same type (e.g., per-module heatmaps, cluster markers), keep dimensions and styling consistent so they can be combined in a figure:
width and height in ggsave() for all plots of a typebase_size vary between related plotsscale_fill_* / scale_color_* once and reusecoord_fixed() or consistent width/height ratios# Example: define shared parameters for a set of heatmaps
HEATMAP_WIDTH <- 8
HEATMAP_HEIGHT <- 6
HEATMAP_BASE_SIZE <- 10
HEATMAP_COLORS <- scale_fill_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0)
# Apply consistently to each plot
ggsave(filename, plot, width = HEATMAP_WIDTH, height = HEATMAP_HEIGHT)
development
Phylogenetic tree visualization and formatting with ggtree (R) or iTOL (web). Use when rendering a phylogenetic tree as a figure, choosing tree layout, coloring branches or labels by taxonomy, collapsing clades, displaying support values, or adding overlays to a tree. Do NOT load for tree inference (use protein-phylogeny skill) or domain annotation (future separate skill).
development
Configure and manage Claude Code security protections for sensitive files, credentials, and data. Use when the user invokes /security-setup to set up or modify protections against unauthorized file access, credential exposure, or sensitive data leaks.
development
Script organization for data science analysis projects with numbered scripts, data/outs/ directories, and reproducibility conventions. Use when creating new analysis scripts in projects that follow data science conventions (numbered XX_ prefix scripts, outs/ directories, BUILD_INFO.txt). Do NOT load for documentation projects (Quarto books), infrastructure repos, or projects without data/outs/ directory structure.
testing
R renv package management for data science projects. Use when working with renv (renv.lock, renv::restore, renv::snapshot) in R analysis projects. Do NOT load for projects that do not use R or renv.