📦 学术图表
v1.0.0一键生成可发表的学术图表,支持7种图表类型(条形图、热力图、散点图、折线图、箱线图、森林图、小提琴图)、4种配色……
详细分析 ▾
运行时依赖
安装命令
点击复制技能文档
学术图表 — 出版级图表生成器 从 JSON/CSV 数据一键出图。本地运行,数据不出机。
快速开始 # 带 CJK 支持的柱状图 python3 scripts/gen_figure.py -t bar -d data.json -o figure.png --cjk \ --title "图2 主标题 / Subtitle" --ylabel "准确率 Accuracy (%)"
# 热力图 python3 scripts/gen_figure.py -t heatmap -d data.json -o heatmap.png --cjk \ --cmap RdBu_r --vmin -20 --vmax 45
# 带趋势线散点图 python3 scripts/gen_figure.py -t scatter -d data.csv -o scatter.png \ --xlabel "Baseline (%)" --ylabel "Gain (%)" --theme nature
图表类型 Type Key Features Bar -t bar 分组柱、误差线、显著性括号 Heatmap -t heatmap 单元格标注、自定义 colormap、colorbar Scatter -t scatter 趋势线、r 值、颜色分组、均值点 Line -t line 多系列、误差带、标记 Box -t box 箱线图、抖动点 Forest -t forest CI 须、总钻石、参考线 Violin -t violin 密度估计、内均值/中位数
配色主题 --theme nature Nature 期刊配色(鲜明、易区分) --theme lancet Lancet 医学配色(高对比) --theme conservative 专业低饱和(通用安全) --theme default 平衡百搭
中文支持 加 --cjk 自动检测并加载系统 CJK 字体,零配置。 python3 scripts/gen_figure.py -t bar -d data.json -o fig.png --cjk 字体优先级:Noto Sans CJK → PingFang → Microsoft YaHei → WQY → AR PL → Droid 自定义:--cjk-font /path/to/font.ttf
数据输入 JSON(全功能)或 CSV(基础)。格式详见 references/data-formats.md JSON 柱状图示例: { "labels": ["Group A", "Group B"], "series": {"Treatment": [75, 82], "Control": [68, 70]}, "errors": {"Treatment": [3, 2], "Control": [2, 1]}, "significance": {"Treatment:0": "***", "Control:1": "NS"} }
关键参数 --title "text" 标题(支持 \n 换行) --xlabel, --ylabel 轴标签 --width N, --height N 图尺寸(英寸) --show-values 柱上显示数值 --no-trend 隐藏趋势线(散点) --no-legend 隐藏图例 --cmap NAME colormap(热力图) --vmin, --vmax 数值范围(热力图)
输出 .png 默认 300 DPI 位图 .svg 矢量图(--out 指定 .svg 扩展名)
脚本调用(非 CLI) 若通过 Python 脚本生成:
- 先 detect_cjk_font()
- CJK 文本统一用 fontproperties=font_prop
- plt.rcParams['axes.unicode_minus']=False
- 验证:多标签图 >20 KB 表示字体已载入
- 推荐输出:PNG 300 DPI,bbox_inches='tight',白底