Skip to content

Jack-5732/r-plot-templates

Repository files navigation

R Plot Templates — 54+ Publication-Ready Scientific Plot Templates


English

GitHub stars License: MIT Contributions Welcome Templates

Standardized R/ggplot2 plot templates for bioinformatics and scientific research. Each template is a standalone, runnable R script with mock data, SCI journal color palettes, and dual output (PDF + TIFF).

Two Ways to Use

1. Claude Code Skill (AI-Assisted)

Install as a Claude Code plugin for AI-powered plot generation:

claude plugin add Jack-5732/r-plot-templates

Then simply describe what you want to plot in natural language. Claude will match the right template and generate publication-ready code.

2. Direct R Script Copy

Clone the repo and source() any template:

git clone https://github.com/Jack-5732/r-plot-templates.git
# In R
source("templates/01-basic/01_barplot.R")

Template Catalog

Category # Templates
Basic 7 Bar, Scatter, Line, Box, Dot, Unpaired Box-Scatter, Paired Box-Scatter
Distribution 3 Violin, Density, Histogram
Statistics 3 Volcano, Venn, Forest
Enrichment 3 GSEA Mountain, GSEA Dot, GSEA Ridge
Heatmap 3 Genomic, Correlation, Circular
Survival 3 KM Curve, Dual-Gene Survival, Nomogram
Dim. Reduction 2 PCA, UMAP
Special 8 Sankey, Lollipop, Radar, Cleveland Dot, Bubble, 2D Density, Waterfall, Significance
Single Cell 4 Seurat UMAP, VlnPlot, DotPlot, FeaturePlot
Total 36+

Quick Start

git clone https://github.com/Jack-5732/r-plot-templates.git
cd r-plot-templates
# Open R in the project directory
setwd("templates/01-basic")

# Run any template — all scripts are self-contained with mock data
source("01_barplot.R")
source("02_scatter.R")
source("06_boxplot_scatter_unpaired.R")

Replace the mock data section with your own data frame, adjust variable names, and you're ready to submit.

Coding Standards

All templates follow these conventions:

  • Theme: theme_classic() or theme_bw() as base
  • Colors: ggsci journal palettes (Lancet, JCO, NPG, AAAS)
  • Axes: coord_cartesian() — never xlim()/ylim()
  • Pipe: %>% exclusively, no |> mixing
  • Output: PDF (cairo_pdf for editing) + TIFF (300 dpi, LZW compression)
  • Comments: Chinese, explaining why not what
  • No nesting: Linear pipe chains, step-by-step execution

Project Structure

r-plot-templates/
├── .claude-plugin/plugin.json    # Claude Code plugin metadata
├── skills/                       # Claude Code skill files
│   └── r-plot-templates/
│       ├── SKILL.md
│       └── references/           # Markdown template references
├── templates/                    # Standalone R scripts
│   ├── 01-basic/
│   ├── 02-distribution/
│   ├── 03-statistics/
│   ├── 04-enrichment/
│   ├── 05-heatmap/
│   ├── 06-survival/
│   ├── 07-dimreduction/
│   ├── 08-special/
│   └── 09-singlecell/
├── README.md                     # This file
├── README_CN.md                  # 中文文档(主文档)
├── CONTRIBUTING.md               # Contribution guide (中文)
├── CONTRIBUTING_EN.md            # Contribution guide (English)
├── TEMPLATE_FORMAT.md            # Template standard format
├── LICENSE                       # MIT
└── CHANGELOG.md

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

See TEMPLATE_FORMAT.md for the standard template format.

License

MIT License — free for academic and commercial use.

Acknowledgments

Curated from 54+ R plotting scripts across bioinformatics projects, with standardization for community reuse.


中文版本

R 绘图模板 — 54+ 出版级科学绘图模板

GitHub stars License: MIT Contributions Welcome Templates

为生物信息学和科学研究提供的标准化 R/ggplot2 绘图模板。每个模板都是一个独立、可运行的 R 脚本,包含示例数据、SCI 期刊配色方案和双重输出(PDF + TIFF)。

两种使用方式

1. Claude Code 技能(AI 辅助)

安装为 Claude Code 插件以获得 AI 支持的绘图生成:

claude plugin add Jack-5732/r-plot-templates

只需用自然语言描述您想绘制的内容。Claude 将匹配正确的模板并生成出版级代码。

2. 直接复制 R 脚本

克隆存储库并 source() 任何模板:

git clone https://github.com/Jack-5732/r-plot-templates.git
# 在 R 中
source("templates/01-basic/01_barplot.R")

模板目录

分类 数量 模板
基础 7 柱状图、散点图、折线图、箱线图、点图、非配对箱线图-散点图、配对箱线图-散点图
分布 3 小提琴图、密度图、直方图
统计 3 火山图、韦恩图、森林图
富集 3 GSEA 山图、GSEA 点图、GSEA 岭图
热力图 3 基因组、相关性、圆形
生存 3 KM 曲线、双基因生存、列线图
降维 2 PCA、UMAP
特殊 8 Sankey、棒棒糖、雷达、Cleveland 点、气泡、2D 密度、瀑布、显著性
单细胞 4 Seurat UMAP、VlnPlot、DotPlot、FeaturePlot
总计 36+

快速开始

git clone https://github.com/Jack-5732/r-plot-templates.git
cd r-plot-templates
# 在项目目录中打开 R
setwd("templates/01-basic")

# 运行任何模板 — 所有脚本都是独立的,包含示例数据
source("01_barplot.R")
source("02_scatter.R")
source("06_boxplot_scatter_unpaired.R")

将示例数据部分替换为您自己的数据框,调整变量名称,就可以提交了。

编码标准

所有模板遵循这些约定:

  • 主题: theme_classic()theme_bw() 作为基础
  • 颜色: ggsci 期刊配色(柳叶刀、JCO、NPG、AAAS)
  • 坐标轴: coord_cartesian() — 永不使用 xlim()/ylim()
  • 管道: 仅使用 %>%,不混合 |>
  • 输出: PDF(cairo_pdf 以便编辑)+ TIFF(300 dpi,LZW 压缩)
  • 注释: 中文,解释为什么而不是什么
  • 无嵌套: 线性管道链,逐步执行

项目结构

r-plot-templates/
├── .claude-plugin/plugin.json    # Claude Code 插件元数据
├── skills/                       # Claude Code 技能文件
│   └── r-plot-templates/
│       ├── SKILL.md
│       └── references/           # Markdown 模板参考
├── templates/                    # 独立 R 脚本
│   ├── 01-basic/
│   ├── 02-distribution/
│   ├── 03-statistics/
│   ├── 04-enrichment/
│   ├── 05-heatmap/
│   ├── 06-survival/
│   ├── 07-dimreduction/
│   ├── 08-special/
│   └── 09-singlecell/
├── README.md                     # 本文件
├── README_CN.md                  # 中文文档(主文档)
├── CONTRIBUTING.md               # 贡献指南(中文)
├── CONTRIBUTING_EN.md            # 贡献指南(英文)
├── TEMPLATE_FORMAT.md            # 模板标准格式
├── LICENSE                       # MIT
└── CHANGELOG.md

贡献

我们欢迎贡献!有关指南,请参阅 CONTRIBUTING.md

有关标准模板格式,请参阅 TEMPLATE_FORMAT.md

许可证

MIT 许可 — 免费用于学术和商业用途。

鸣谢

从生物信息学项目中的 54+ R 绘图脚本进行整理,针对社区重用进行了标准化。

About

54+ publication-ready R bindplot templates for bindbioinformatics bindand scientific research bindband| bindClaude bindCode bindSkill + bindstandalone R scripts

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages