From research-writing-assistant
Generates publication-quality Python plots for scientific papers using matplotlib/seaborn, top-journal color schemes like Nature/Science, 450 DPI PNG/SVG exports, and data manifests.
npx claudepluginhub norman-bury/research-writing-skillThis skill uses the workspace's default tool permissions.
本技能指导使用 Python 生成科研论文级别的数据图表。
Creates journal-ready scientific plots with matplotlib, seaborn, plotly. Supports multi-panel layouts, error bars, significance markers, colorblind-safe palettes, PDF/EPS/TIFF exports.
Creates publication-ready scientific figures with matplotlib/seaborn/plotly, including multi-panel layouts, error bars, significance annotations, colorblind-safe palettes, and journal formatting for Nature, Science, Cell.
Guides chart type selection by data structure, color palettes for accessibility/print, figure composition, and journal formatting for scientific publications. Use when preparing data visualizations for talks or submissions.
Share bugs, ideas, or general feedback.
本技能指导使用 Python 生成科研论文级别的数据图表。
默认环境名:research
激活命令:
conda activate research
必需库:
pip install matplotlib seaborn numpy pandas
如环境未配置,调用 environment-setup 技能。
任何数据图都必须先有数据文件和数据清单(data manifest)。默认路径:
figures/data-manifest.md
figures/data/<figure-name>.csv
figures/<section>/<figure-name>.py
figures/<section>/<figure-name>.png
figures/<section>/<figure-name>.svg
figures/data-manifest.md 至少记录:
| Figure | Data file | Real/mock | Source | Script | Outputs |
|---|
mock 或 synthetic 数据只允许用于规划版图表。文件名必须以 mock_ 或 synthetic_ 开头,并在图表、表格或章节草稿中保留 [待真实实验替换]。不得把 mock 数据写成“实验结果表明”。
| 用途 | DPI | 说明 |
|---|---|---|
| 期刊投稿 | 300-600 | 大多数期刊要求 |
| 顶刊投稿 | 450+ | Nature/Science等 |
| 屏幕展示 | 150 | PPT/网页 |
本技能默认使用 450 DPI
每张图同时输出两种格式:
| 类型 | 宽度(英寸) | 适用场景 |
|---|---|---|
| 单栏图 | 3.5 | 期刊单栏 |
| 双栏图 | 7.0 | 期刊双栏/全宽 |
| PPT图 | 10.0 | 演示文稿 |
NATURE_COLORS = ['#2E86AB', '#A23B72', '#F18F01', '#C73E1D', '#95C623']
CELL_COLORS = ['#4E79A7', '#F28E2B', '#E15759', '#76B7B2', '#59A14F', '#EDC948']
COLORBLIND_SAFE = ['#0077BB', '#33BBEE', '#009988', '#EE7733', '#CC3311', '#EE3377']
"""
Figure X: [图表标题]
论文章节: [所属章节]
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
from pathlib import Path
# 中文字体配置
CHINESE_FONT = None
font_candidates = [
'/System/Library/Fonts/STHeiti Light.ttc',
'/System/Library/Fonts/PingFang.ttc',
]
for fp in font_candidates:
if Path(fp).exists():
CHINESE_FONT = fm.FontProperties(fname=fp)
break
plt.rcParams['axes.unicode_minus'] = False
# 顶刊配色
COLORS = ['#4E79A7', '#F28E2B', '#E15759', '#76B7B2', '#59A14F']
def setup_plot_style():
plt.rcParams.update({
'font.size': 10,
'axes.titlesize': 12,
'axes.labelsize': 10,
'axes.spines.top': False,
'axes.spines.right': False,
'axes.grid': True,
'grid.alpha': 0.3,
'legend.frameon': False,
'savefig.dpi': 450,
'savefig.bbox': 'tight',
})
def main():
setup_plot_style()
fig, ax = plt.subplots(figsize=(7, 5))
# === 绑定代码 ===
x = np.linspace(0, 10, 100)
ax.plot(x, np.sin(x), color=COLORS[0], label='Model A')
ax.plot(x, np.cos(x), color=COLORS[1], label='Model B')
if CHINESE_FONT:
ax.set_xlabel('时间 (s)', fontproperties=CHINESE_FONT)
ax.set_ylabel('幅值', fontproperties=CHINESE_FONT)
else:
ax.set_xlabel('Time (s)')
ax.set_ylabel('Amplitude')
ax.legend()
# === 绑定代码结束 ===
# 保存
output_dir = Path(__file__).parent
fig_name = Path(__file__).stem
plt.savefig(output_dir / f'{fig_name}.png', dpi=450)
plt.savefig(output_dir / f'{fig_name}.svg')
plt.show()
if __name__ == '__main__':
main()
ax.plot(x, y, color=COLORS[0], linewidth=1.5, marker='o', markersize=4)
ax.bar(x_pos, values, color=COLORS[:len(values)], edgecolor='white')
im = ax.imshow(matrix, cmap='RdBu_r', aspect='auto')
plt.colorbar(im, ax=ax)
bp = ax.boxplot(data_list, patch_artist=True)
for patch, color in zip(bp['boxes'], COLORS):
patch.set_facecolor(color)
ax.scatter(x, y, c=colors, s=sizes, alpha=0.6, cmap='viridis')
figures/
├── chapter1/
│ ├── fig1_overview.py
│ ├── fig1_overview.png
│ └── fig1_overview.svg
├── chapter2/
└── chapter3/
fig{序号}_{描述}.pyfig1_model_architecture.pyfrom matplotlib.font_manager import FontProperties
font = FontProperties(fname='/System/Library/Fonts/STHeiti Light.ttc')
ax.set_xlabel('中文标签', fontproperties=font)
plt.savefig('figure.png', dpi=450, bbox_inches='tight')
ax.legend(loc='upper left', bbox_to_anchor=(1.02, 1))