Generating Publication-Ready Figures in R
This skill specializes in transforming ordinary ggplot2 plots into professional, publication-ready figures that meet the strict standards of top-tier journals like Nature, Science, Cell, and others.
Use this skill when the user wants to:
- - Convert ggplot plots to journal-style figures
- Apply Nature/Science publication themes to existing plots
- Create multi-panel figures with consistent styling
- Export figures with proper DPI, dimensions, and formats
- Match specific journal submission guidelines
- Create colorblind-safe and publication-quality color schemes
What This Skill Does
When activated, this skill will:
- 1. Analyze existing ggplot code - Read and understand the current plot structure
- 2. Apply journal themes - Add publication-quality themes including:
- Proper font sizes and families
- Clean axis lines and backgrounds
- Journal-specific color palettes
- Legend positioning and styling
- 3. Optimize for submission - Ensure figures meet:
- DPI requirements (typically 300-600 DPI)
- Width/height specifications (single vs double column)
- File format requirements (TIFF, PDF, EPS)
- Color space requirements (CMYK vs RGB)
- 4. Create multi-panel figures - Combine plots using:
-
patchwork for simple layouts
-
cowplot for complex compositions
- Custom annotation and labeling
- 5. Export properly - Save with correct:
- Resolution (DPI)
- Dimensions (inches/cm)
- File format
- Color profile
Example User Requests That Should Trigger This Skill
- - "Transform this ggplot to Nature journal style"
- "Make this figure publication-ready for Science"
- "Create a two-column figure matching Cell format"
- "Export these plots at 600 DPI for submission"
- "Apply a colorblind-safe palette to my plots"
- "Combine these four plots into one publication figure"
- "Format my scatter plot for PNAS submission"
Journal Style Guidelines
Nature Style
- - Font: Arial or Helvetica
- Font sizes: Axis titles 7-9 pt, axis labels 6-8 pt
- Single column: 89 mm (3.5 in) width
- Double column: 183 mm (7.2 in) width
- Max height: 234 mm (9.2 in)
- Resolution: 300-600 DPI
- Formats: TIFF, PDF, EPS (vector preferred)
Science Style
- - Font: Arial
- Font sizes: Title 9 pt, labels 7 pt
- Single column: 57 mm (2.25 in) width
- Double column: 114 mm (4.5 in) width
- Resolution: 300-600 DPI
- Formats: TIFF, PDF, EPS
Cell Press Style
- - Font: Arial or Helvetica
- Single column: 85 mm (3.3 in) width
- Double column: 178 mm (7 in) width
- Resolution: 300 DPI minimum
- Formats: TIFF, EPS, PDF
Theme Templates Available
theme_nature()
Clean, minimalist theme matching Nature journals:
- - No gray backgrounds
- Minimal grid lines
- Arial font family
- Proper axis sizing
theme_science()
Theme for Science journal submissions:
- - Compact layout
- Clean typography
- Optimized for smaller widths
theme_cellpress()
Cell Press journal theme:
- - Professional appearance
- Flexible legend placement
- Publication-ready defaults
theme_colorblind()
Colorblind-safe palette with:
- - Viridis/Colorbrewer schemes
- High contrast ratios
- Print-friendly colors
Color Palettes
Nature-Approved Colors
CODEBLOCK0
Colorblind-Safe Scales
- - INLINECODE6
- INLINECODE7 (Okabe-Ito palette)
- INLINECODE8
Example Workflow
User: Here's my ggplot code, make it Nature-style.
CODEBLOCK1
Skill transforms to:
CODEBLOCK2
Multi-Panel Figures
CODEBLOCK3
Tools & Packages Commonly Used
| Purpose | R Packages |
|---|
| Base plotting | ggplot2 |
| Themes |
ggplot2, cowplot, hrbrthemes |
| Color palettes | viridis, RColorBrewer, scales, ggsci |
| Multi-panel | patchwork, cowplot, ggpubr |
| Export | ggplot2, ragg |
| Fonts | extrafont, showtext |
| Annotations | ggrepel, ggpp |
Common Journal Requirements
| Journal | Width (single) | Width (double) | Max Height | Min DPI |
|---|
| Nature | 89 mm | 183 mm | 234 mm | 300 |
| Science |
57 mm | 114 mm | 229 mm | 300 |
| Cell | 85 mm | 178 mm | 229 mm | 300 |
| PNAS | 87 mm | 178 mm | 227 mm | 300 |
| PLOS ONE | 170 mm | - | 230 mm | 300 |
| eLife | 183 mm | - | 244 mm | 300 |
Quick Reference
Applying a theme
CODEBLOCK4
Export formats
CODEBLOCK5
Common fixes
- - Text too small: Increase
base_size in theme - Legend overlap: Use INLINECODE10
- Colors not distinct: Use INLINECODE11
- Fonts not rendering: Use INLINECODE12
Notes
- - Always check specific journal guidelines before submission
- Vector formats (PDF/EPS) are preferred over raster
- Use consistent styling across all figures in a paper
- Test colorblind accessibility with
colorblindr package - Keep axis labels clear and concise
- Avoid redundant chart junk (backgrounds, grid lines)
在R中生成可发表级别的图表
本技能专注于将普通的ggplot2图表转换为专业、可发表级别的图表,满足《自然》《科学》《细胞》等顶级期刊的严格标准。
当用户希望实现以下目标时,请使用本技能:
- - 将ggplot图表转换为期刊风格图表
- 为现有图表应用《自然》/《科学》发表主题
- 创建风格一致的多面板图表
- 以正确的DPI、尺寸和格式导出图表
- 匹配特定期刊的投稿指南
- 创建色盲友好且符合发表质量的颜色方案
本技能的功能
激活后,本技能将:
- 1. 分析现有ggplot代码 - 读取并理解当前图表结构
- 2. 应用期刊主题 - 添加发表质量的主题,包括:
- 合适的字体大小和字体族
- 清晰的坐标轴线和背景
- 期刊特定的调色板
- 图例定位和样式
- 3. 优化投稿格式 - 确保图表满足:
- DPI要求(通常为300-600 DPI)
- 宽度/高度规格(单栏 vs 双栏)
- 文件格式要求(TIFF、PDF、EPS)
- 色彩空间要求(CMYK vs RGB)
- 4. 创建多面板图表 - 使用以下工具组合图表:
- patchwork 用于简单布局
- cowplot 用于复杂组合
- 自定义注释和标签
- 5. 正确导出 - 以正确的格式保存:
- 分辨率(DPI)
- 尺寸(英寸/厘米)
- 文件格式
- 色彩配置文件
应触发本技能的用户请求示例
- - 将这个ggplot转换为《自然》期刊风格
- 让这个图表达到《科学》期刊的发表标准
- 创建一个符合《细胞》格式的双栏图表
- 以600 DPI导出这些图表用于投稿
- 为我的图表应用色盲友好调色板
- 将这四张图组合成一个发表图表
- 格式化我的散点图用于PNAS投稿
期刊风格指南
《自然》风格
- - 字体:Arial 或 Helvetica
- 字体大小:坐标轴标题7-9 pt,坐标轴标签6-8 pt
- 单栏:89 mm(3.5英寸)宽度
- 双栏:183 mm(7.2英寸)宽度
- 最大高度:234 mm(9.2英寸)
- 分辨率:300-600 DPI
- 格式:TIFF、PDF、EPS(优先矢量格式)
《科学》风格
- - 字体:Arial
- 字体大小:标题9 pt,标签7 pt
- 单栏:57 mm(2.25英寸)宽度
- 双栏:114 mm(4.5英寸)宽度
- 分辨率:300-600 DPI
- 格式:TIFF、PDF、EPS
《细胞》出版社风格
- - 字体:Arial 或 Helvetica
- 单栏:85 mm(3.3英寸)宽度
- 双栏:178 mm(7英寸)宽度
- 分辨率:最低300 DPI
- 格式:TIFF、EPS、PDF
可用的主题模板
theme_nature()
简洁、极简主题,匹配《自然》期刊:
- - 无灰色背景
- 最简网格线
- Arial字体族
- 合适的坐标轴尺寸
theme_science()
《科学》期刊投稿主题:
theme_cellpress()
《细胞》出版社期刊主题:
theme_colorblind()
色盲友好调色板,包含:
- - Viridis/Colorbrewer方案
- 高对比度
- 打印友好颜色
调色板
《自然》认可颜色
r
主要颜色
nature_colors <- c(
blue = #3B4992,
red = #EE0000,
green = #008B45,
purple = #631879
)
色盲友好色阶
- - scalefillviridis()
- scalecolorokabeito()(Okabe-Ito调色板)
- scalecolor_viridis()
示例工作流程
用户: 这是我的ggplot代码,请将其转换为《自然》风格。
r
原始图表
p <- ggplot(mtcars, aes(x = wt, y = mpg, color = factor(cyl))) +
geom_point(size = 3)
技能转换为:
r
发表就绪版本
p <- ggplot(mtcars, aes(x = 重量(吨), y = 燃油效率(mpg),
color = 气缸数)) +
geom_point(size = 2.5, shape = 16, alpha = 0.8) +
scale
colornature() +
theme
nature(basesize = 8) +
labs(title = NULL)
以正确尺寸导出
ggsave(figure1.pdf, p, width = 3.5, height = 3, dpi = 300,
device = pdf)
多面板图表
r
使用patchwork组合图表
library(patchwork)
figure1 <- (panela | panelb) / (panelc | paneld)
添加面板标签
figure1 <- figure1 +
plot
annotation(taglevels = A,
tag_suffix = ))
导出
ggsave(figure1.pdf, figure1, width = 7, height = 6, dpi = 300)
常用工具与包
ggplot2, cowplot, hrbrthemes |
| 调色板 | viridis, RColorBrewer, scales, ggsci |
| 多面板 | patchwork, cowplot, ggpubr |
| 导出 | ggplot2, ragg |
| 字体 | extrafont, showtext |
| 注释 | ggrepel, ggpp |
常见期刊要求
| 期刊 | 宽度(单栏) | 宽度(双栏) | 最大高度 | 最低DPI |
|---|
| Nature | 89 mm | 183 mm | 234 mm | 300 |
| Science |
57 mm | 114 mm | 229 mm | 300 |
| Cell | 85 mm | 178 mm | 229 mm | 300 |
| PNAS | 87 mm | 178 mm | 227 mm | 300 |
| PLOS ONE | 170 mm | - | 230 mm | 300 |
| eLife | 183 mm | - | 244 mm | 300 |
快速参考
应用主题
r
p + theme_nature() # 《自然》风格
p + theme_science() # 《科学》风格
p + theme_cellpress() # 《细胞》出版社风格
p + theme_colorblind() # 色盲友好
导出格式
r
矢量格式(推荐)
ggsave(figure.pdf, ... device = pdf)
ggsave(figure.eps, ... device = eps)
栅格格式(高DPI)
ggsave(figure.tiff, ... device = tiff, dpi = 600)
ggsave(figure.png, ... device = png, dpi = 300)
常见问题修复
- - 文字太小:增加主题中的 basesize
- 图例重叠:使用 theme(legend.position = bottom)
- 颜色区分度不够:使用 scalefillviridis()
- 字体无法渲染:使用 extrafont::fontimport()
注意事项
- - 投稿前务必检查具体期刊指南
- 矢量格式(PDF/EPS)优于栅格格式
- 论文中所有图表保持一致的样式
- 使用 colorblindr 包测试色盲可访问性
- 保持坐标轴标签清晰简洁
- 避免冗余的图表装饰(背景、网格线)