使用 Python(matplotlib)或 R(ggplot2)为《自然》系列期刊生成出版级图表。用户需要创建、润色或重新设计图表时触发。
Generate 符合自然组合视觉标准的多面板科学人物: 正确排版、 语义色彩调色板、 可访问设计、 可编辑 SVG 输出是一项面向实际任务的技能。它将相关步骤、工具调用和结果整理方式集中到统一流程中,帮助使用者更快完成目标并减少重复操作。
实际使用前应先确认任务范围、数据来源、运行环境、必要权限和关键参数,再依据技能说明逐步执行;若输入条件不完整,应先补齐信息或采用保守配置,避免因错误假设导致结果偏离需求。
执行过程中需要关注工具调用是否成功、接口或依赖是否可用、输出格式是否符合预期,并对异常提示、缺失字段和边界情况进行处理;涉及批量任务时,还应保存进度,避免中断后重复操作。
生成符合 Nature 期刊系列视觉规范的多面板科研图表:字体规范、语义化配色方案、无障碍可访问设计,并输出可编辑的 SVG 格式文件。
当用户提及以下任一内容时激活:
| 格式 | 宽度 | 分辨率 |
|---|---|---|
| 单栏 | 89 mm(3.5 英寸) | ≥300 DPI |
| 1.5 栏 | 120 mm(4.7 英寸) | ≥300 DPI |
| 双栏 | 183 mm(7.2 英寸) | ≥300 DPI |
| 线条图(Line art) | 不限 | 600 DPI |
| 最终投稿文件 | PDF 或 TIFF | 优先使用矢量格式 |
NATURE_COLORS = {
"blue": "#4878CF",
"red": "#D65F5F",
"green": "#6ACC65",
"orange": "#EE854A",
"purple": "#956CB4",
"teal": "#82C6E2",
"brown": "#D5BB67",
"gray": "#8C8C8C",
# 色觉障碍友好主色对:
"cb_blue": "#0072B2",
"cb_orange":"#E69F00",
}
若用户提供 CSV、Excel 或 JSON 数据文件:
python3 ~/.openclaw/workspace/skills/nature-paper-hub/scripts/auto_figure.py --input--output ~/Downloads/figure_ .pdf --title "[figure title]" --xlabel "X axis label" --ylabel "Y axis label" --type [auto|line|bar|scatter|heatmap|box]
该脚本将自动识别列类型、选择合适图表类型、应用 Nature 风格,并输出 PDF 与 PNG 文件。
向用户提问:
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import numpy as np
# --- Nature 风格设置 ---
plt.rcParams.update({
'font.family': 'Arial',
'font.size': 8,
'axes.linewidth': 0.8,
'axes.spines.top': False,
'axes.spines.right': False,
'xtick.major.width': 0.8,
'ytick.major.width': 0.8,
'xtick.major.size': 3,
'ytick.major.size': 3,
'xtick.direction': 'out',
'ytick.direction': 'out',
'figure.dpi': 300,
'savefig.dpi': 300,
'savefig.bbox': 'tight',
'savefig.pad_inches': 0.05,
'pdf.fonttype': 42, # PDF 中文字可编辑
'ps.fonttype': 42,
})
COLORS = {
"blue": "#4878CF", "red": "#D65F5F", "green": "#6ACC65",
"orange": "#EE854A", "purple": "#956CB4", "teal": "#82C6E2",
"cb_blue": "#0072B2", "cb_orange": "#E69F00",
}
# --- 图表布局 ---
fig = plt.figure(figsize=(7.2, 4.0)) # 双栏宽度,高度可调
gs = gridspec.GridSpec(1, 3, figure=fig, wspace=0.4, hspace=0.4)
ax_a = fig.add_subplot(gs[0])
ax_b = fig.add_subplot(gs[1])
ax_c = fig.add_subplot(gs[2])
# --- 面板标签 ---
for ax, label in zip([ax_a, ax_b, ax_c], ['a', 'b', 'c']):
ax.text(-0.15, 1.05, label, transform=ax.transAxes,
fontsize=8, fontweight='bold', va='top', ha='right')
# --- 此处填入您的数据 ---
# ax_a: ...
# ax_b: ...
# ax_c: ...
plt.savefig('figure1.pdf', format='pdf')
plt.savefig('figure1.png', dpi=300)
print("Saved: figure1.pdf, figure1.png")
library(ggplot2)
library(patchwork)
# Nature 主题
theme_nature <- function() {
theme_classic(base_size = 8, base_family = "Arial") +
theme(
axis.line = element_line(linewidth = 0.5),
axis.ticks = element_line(linewidth = 0.5),
axis.ticks.length = unit(2, "pt"),
strip.background = element_blank(),
legend.key.size = unit(3, "mm"),
plot.margin = margin(2, 2, 2, 2, "mm")
)
}
nature_colors <- c(
blue = "#4878CF", red = "#D65F5F", green = "#6ACC65",
orange = "#EE854A", purple = "#956CB4", teal = "#82C6E2"
)
# --- 此处填入您的图表代码 ---
# p1 <- ggplot(...) + theme_nature()
# p2 <- ggplot(...) + theme_nature()
# combined <- p1 | p2
# ggsave("figure1.pdf", combined, width = 183, height = 80, units = "mm", dpi = 300)
输出前务必检查以下各项:
生成配套的图注文字:
使用带标记点的实线;不同组别采用不同线型 + 颜色区分。
类别较多时建议使用横向柱状图;应在柱体上叠加原始数据点。
使用 plt.bar() 并设置 edgecolor='black', linewidth=0.5。
若用于展示相关性,须添加回归线及 95% 置信区间(CI)。 图中需标明 Pearson/Spearman 相关系数 r 与 p 值。
相关性分析宜用发散型色阶(如 RdBu_r),强度表达宜用顺序型色阶。
必须包含带标签和单位的色标(colorbar)。
必须叠加原始数据点(使用 stripplot 或 geom_jitter)。
需注明每组样本量 n。
推荐使用 BioRender(biorender.com)或 Inkscape 绘制示意图。 导出为 SVG 后嵌入主图。
向用户提供以下全部内容:
相关专题
热门下载
相关下载
精品课程
共6课时 | 54.7万人学习
共89课时 | 134万人学习
共49课时 | 82.5万人学习
最新文章