| name | RGraphMaker |
|---|---|
| description | Generate publication-ready graphs and data visualizations using R — no R knowledge required. Use this skill whenever the user asks to create, plot, chart, graph, or visualize data using R, or when they upload a dataset (CSV, TSV, Excel) and want any kind of visual output. Triggers on phrases like: "make a bar chart", "plot this data", "create a volcano plot", "visualize my results", "R graph", "ggplot", "heatmap of my data", "scatter plot", "box plot comparison", "interactive chart", "survival curve", "Manhattan plot", "Sankey diagram", "forest plot", "word cloud", "treemap", "network graph", "QQ plot", "ridgeline plot", "Venn diagram", "radar chart", "waterfall chart", or any request for a statistical/scientific figure. Also triggers when the user has data and says things like "show me the distribution", "compare these groups", "what does this data look like", or "publication figure". Supports 50 graph types via ggplot2, base R, and plotly. Outputs PNG, PDF, and/or interactive HTML. |
This skill lets anyone create professional R visualizations by describing what they want in plain language. The user never writes R code — you generate, execute, and deliver the output.
- Understand the request — What graph type? What data? What customizations?
- Load or inspect the data — Read the user's CSV/TSV/Excel, or use inline data
- Auto-suggest (if no graph type specified) — Run
scripts/data_profiler.Ron the data - Look up the graph pattern — Find the right reference file from the routing table below
- Select the engine — ggplot2 (default), base R, or plotly
- Generate the R script — Adapt the template to the user's data and preferences
- Apply customizations — Colors, themes, labels per
references/customization_guide.md - Execute — Run via
Rscript, save outputs to/mnt/user-data/outputs/ - Present — Share the file(s) with the user
When the user uploads a dataset without specifying a graph type (e.g., "what graphs can I make from this data?" or "analyze my data and suggest visualizations"), run:
Rscript scripts/data_profiler.R /path/to/data.csvThe profiler outputs JSON with:
- Data profile: rows, columns, types (numeric/categorical/date), missing data %
- Domain detection: auto-detects DESeq2, GWAS, survival, flow, network, word frequency data
- Ranked recommendations: each with graph type, priority (HIGH/MEDIUM/LOW), reason, suggested column mappings (x, y, group), engine, and category
How to present recommendations to the user:
- Summarize the data profile (rows, columns, types detected)
- Mention any domain detected (e.g., "This looks like differential expression data")
- Present the HIGH-priority recommendations first as the top picks
- List MEDIUM recommendations as additional options
- Mention LOW-priority ones briefly as "also possible"
- Ask which graph(s) the user wants to create
- When the user picks one, use the suggested columns from the profiler output
Domain detection triggers:
- DESeq2: columns matching log2FC + padj/pvalue + gene → Volcano, MA Plot
- GWAS: CHR + BP/position + pvalue → Manhattan Plot
- Survival: time + status columns → Kaplan-Meier
- Flow: source + target columns → Sankey / Alluvial
- Network: node/edge columns → Network Graph
- Word frequency: word + freq/count columns → Word Cloud
Use this table to find the right reference file. Read the relevant file before generating code.
| # | Graph Type | Variants |
|---|---|---|
| 1 | Bar chart | vertical, horizontal, grouped, stacked, percentage |
| 2 | Line chart | single, multi-line, time series |
| 3 | Scatter plot | basic, regression, colored, bubble, labeled |
| 4 | Histogram | basic, overlaid, faceted |
| 5 | Density plot | basic, overlaid, ridgeline |
| 6 | Area chart | basic, stacked, proportional |
| 7 | Pie / Donut chart | pie, donut, labeled |
| # | Graph Type | Variants |
|---|---|---|
| 8 | Boxplot | basic, grouped, jitter, notched |
| 9 | Violin plot | basic, with boxplot, split |
| 10 | Ridgeline / Joy plot | basic, quantile-colored |
| 11 | Dot plot (Cleveland) | basic, grouped |
| 12 | Strip / Jitter plot | basic, grouped, beeswarm |
| 13 | QQ plot | basic, grouped |
| 14 | Error bar plot | bar+error, pointrange |
| 15 | Forest plot | meta-analysis style |
| 16 | Lollipop chart | basic, horizontal, colored |
| 17 | Dumbbell chart | basic, colored |
| # | Graph Type | Variants |
|---|---|---|
| 18 | Heatmap | tile, clustered, annotated |
| 19 | Correlation matrix | corrplot, GGally, interactive |
| 20 | Pairs / Scatter matrix | GGally ggpairs |
| 21 | PCA biplot | manual ggplot, factoextra |
| # | Graph Type | Variants |
|---|---|---|
| 22 | Volcano plot | ggplot2, plotly interactive |
| 23 | MA plot | log-ratio vs mean |
| 24 | Manhattan plot | GWAS-style |
| 25 | Venn diagram | 2-5 sets |
| 26 | UpSet plot | alternative to Venn for many sets |
| 27 | Survival curve | Kaplan-Meier with risk table |
| # | Graph Type | Variants |
|---|---|---|
| 28 | Waterfall chart | financial, sorted |
| 29 | Slope chart | paired comparison |
| 30 | Treemap | basic, grouped |
| 31 | Waffle chart | grid-based proportions |
| 32 | Sankey / Alluvial | flow diagram |
| 33 | Radar / Spider chart | multi-axis comparison |
| 34 | Network graph | igraph, interactive |
| 35 | Word cloud | basic, shaped |
| 36 | ACF / PACF | autocorrelation time series |
| # | Graph Type | Variants |
|---|---|---|
| 37 | Connected scatter plot | basic, with labels, with arrows |
| 38 | 2D density plot | contour, filled, hexbin, bin2d |
| 39 | Parallel coordinates | GGally, plotly interactive |
| 40 | Circular barplot | basic, with labels |
| 41 | Dendrogram | base R, ggdendro, interactive |
| 42 | Circular packing | packcircles, bubble fallback |
| 43 | Chord diagram | circlize, Sankey fallback |
| 44 | Streamgraph | ggplot2, ggstream |
| 45 | Animated chart | gganimate GIF, faceted fallback |
| 46 | Choropleth map | sf, maps, plotly interactive |
| 47 | Bubble map | ggplot2 + maps |
| 48 | 3D scatter / surface | plotly interactive |
| 49 | Diverging stacked bar | Likert-style survey |
| 50 | Table visualization | gt, kableExtra |
| Situation | Engine | Why |
|---|---|---|
| Default / publication figure | ggplot2 | Best aesthetics, most flexible |
| User says "base R" or wants classic style | base R | Simpler, traditional look |
| User wants interactive / hover / zoom | plotly | HTML widget with interactivity |
| User says "interactive" or "hover" | plotly | Automatic interactive trigger |
| Complex static + wants HTML too | ggplot2 → ggplotly() |
Best of both worlds |
Default to PNG + PDF when unspecified. If user says "interactive", produce HTML.
Always save to /mnt/user-data/outputs/.
ggsave("plot.png", plot = p, width = 10, height = 7, dpi = 300) # PNG
ggsave("plot.pdf", plot = p, width = 10, height = 7) # PDF
htmlwidgets::saveWidget(ggplotly(p), "plot.html", selfcontained = TRUE) # HTMLlibrary(readr); library(readxl)
if (grepl("\\.csv$", filepath)) df <- read_csv(filepath)
if (grepl("\\.tsv$", filepath)) df <- read_tsv(filepath)
if (grepl("\\.xlsx?$", filepath)) df <- read_excel(filepath)- Print
colnames(df)andstr(df)first to understand the data - Use actual column names — never guess
- Spaces in names: use backticks
`Column Name` - Ask the user which columns to use if ambiguous
- Always start with library loading — only what's needed
- Always set
set.seed(42)if any randomness is involved - Always wrap main plot in
tryCatch()for graceful error handling - Always print a success message with the output file path
- Package management: Check before loading. If a package is not installed, install it:
if (!requireNamespace("pkgname", quietly = TRUE)) install.packages("pkgname", repos = "https://cloud.r-project.org", quiet = TRUE)
- Source
scripts/theme_presets.Rfor consistent theming when relevant - Read the relevant graph reference file before generating code
Always available (pre-installed): ggplot2, plotly, ggrepel, ggridges, corrplot, heatmaply, GGally, factoextra, cowplot, patchwork, igraph, ggalluvial, ggbeeswarm, ggpubr, ggsci, ggthemes, survival, forecast, scales, dplyr, tidyr, readr, readxl
May need installation: survminer, treemapify, wordcloud, wordcloud2, UpSetR, ggVennDiagram, VennDiagram, waffle, fmsb, tidytext
When a graph type needs a package that may not be installed, the reference files include ggplot2-only fallback patterns that work without extra dependencies. Prefer the dedicated package when available, but fall back to pure ggplot2 if installation fails.
# ============================================================
# Graph: [TYPE] | Engine: [ggplot2/base/plotly]
# Generated by r-graph-maker skill
# ============================================================
# --- Libraries ---
library(ggplot2)
# --- Read Data ---
df <- read.csv("/path/to/data.csv")
# --- Data Preparation ---
# transformations, filtering, factor reordering
# --- Build Plot ---
p <- ggplot(df, aes(x = col1, y = col2)) +
geom_point() +
labs(title = "Title", x = "X", y = "Y") +
theme_minimal(base_size = 14)
# --- Save Outputs ---
ggsave("/mnt/user-data/outputs/plot.png", plot = p, width = 10, height = 7, dpi = 300)
ggsave("/mnt/user-data/outputs/plot.pdf", plot = p, width = 10, height = 7)
cat("Done! Files saved.\n")If the R script fails:
- Read the error message carefully
- Common fixes: wrong column names, factor vs numeric confusion,
na.rm = TRUE - Fix and re-run — don't ask the user to debug
- If data itself is the problem, explain clearly
- Always read user's actual data before generating code — never assume column names
- User uploads are at
/mnt/user-data/uploads/ - Generate R scripts in
/home/claude/, execute, present outputs from/mnt/user-data/outputs/ - For plotly HTML > 5MB, warn the user about file size
- Prefer ggplot2 unless user specifically requests otherwise
- When in doubt about graph type, suggest the best option based on data structure