Scientific Visualization — 科学可视化
v0.1.0用于出版级图表的Meta-skill。创建需要多面板布局、显著性注释、误差条、色盲安全调色板和特定期刊格式(Nature、Science、Cell)的期刊提交图表时使用。编排matplotlib/seaborn/plotly以符合出版风格。对于快速探索,请直接使用seaborn或plotly。
运行时依赖
安装命令
点击复制技能文档
科学可视化概述 科学可视化将数据转换为清晰、准确的图表,以便发表。使用多面板布局、错误条、显著性标记和色盲安全调色板创建期刊级别的图表。使用 matplotlib、seaborn 和 plotly 将图表导出为 PDF/EPS/TIFF 格式,以便用于稿件。 何时使用此技能 此技能应在以下情况下使用: 创建用于科学稿件的图表或可视化 为期刊提交准备图表(Nature、Science、Cell、PLOS 等) 确保图表是色盲友好和可访问的 创建具有统一样式的多面板图表 以正确的分辨率和格式导出图表 遵循特定的出版指南 改进现有的图表以满足出版标准 创建需要在颜色和灰度中均有效的图表 快速入门指南 基本的出版质量图表 import matplotlib.pyplot as plt import numpy as np # 应用出版样式(来自 scripts/style_presets.py) from style_presets import apply_publication_style apply_publication_style('default') # 创建具有适当大小的图表(单列 = 3.5 英寸) fig, ax = plt.subplots(figsize=(3.5, 2.5)) # 绘制数据 x = np.linspace(0, 10, 100) ax.plot(x, np.sin(x), label='sin(x)') ax.plot(x, np.cos(x), label='cos(x)') # 使用单位进行适当标签 ax.set_xlabel('时间(秒)') ax.set_ylabel('幅度(毫伏)') ax.legend(frameon=False) # 删除不必要的边框 ax.spines['top'].set_visible(False) ax.spines['right'].set_visible(False) # 保存为出版格式(来自 scripts/figure_export.py) from figure_export import save_publication_figure save_publication_figure(fig, 'figure1', formats=['pdf', 'png'], dpi=300) 使用预配置样式 使用 assets/ 中的 matplotlib 样式文件应用期刊特定样式: import matplotlib.pyplot as plt # 选项 1:直接使用样式文件 plt.style.use('assets/nature.mplstyle') # 选项 2:使用 style_presets.py 帮助函数 from style_presets import configure_for_journal configure_for_journal('nature', figure_width='single') # 现在创建图表 - 它们将自动匹配 Nature 规范 fig, ax = plt.subplots() # ... 您的绘图代码 ... 使用 Seaborn 快速入门 对于统计图表,使用带有出版样式的 seaborn: import seaborn as sns import matplotlib.pyplot as plt from style_presets import apply_publication_style # 应用出版样式 apply_publication_style('default') sns.set_theme(style='ticks', context='paper', font_scale=1.1) sns.set_palette('colorblind') # 创建统计比较图表 fig, ax = plt.subplots(figsize=(3.5, 3)) sns.boxplot(data=df, x='treatment', y='response', order=['Control', 'Low', 'High'], palette='Set2', ax=ax) sns.stripplot(data=df, x='treatment', y='response', order=['Control', 'Low', 'High'], color='black', alpha=0.3, size=3, ax=ax) ax.set_ylabel('响应(μM)') sns.despine() # 保存图表 from figure_export import save_publication_figure save_publication_figure(fig, 'treatment_comparison', formats=['pdf', 'png'], dpi=300) 核心原则和最佳实践
- 分辨率和文件格式
- 颜色选择 - 色盲无障碍
- 字体和文本