[ PROMPT_NODE_27324 ]
scientific-visualization
[ SKILL_DOCUMENTATION ]
# 科学可视化
## 概述
科学可视化将数据转化为清晰、准确的出版级图表。使用 matplotlib、seaborn 和 plotly 创建包含多面板布局、误差线、显著性标记和色盲友好配色的图表,并导出为 PDF/EPS/TIFF 格式以供论文使用。
## 何时使用此技能
当需要进行以下操作时使用此技能:
- 为科学论文创建图表或可视化内容
- 准备投稿至学术期刊(如 Nature, Science, Cell, PLOS 等)的插图
- 确保图表对色盲用户友好且易于访问
- 制作具有统一风格的多面板图表
- 以正确的分辨率和格式导出图表
- 遵循特定的出版指南
- 改进现有图表以符合出版标准
- 创建在彩色和灰度下均能正常显示的图表
## 快速入门指南
### 基础出版级图表
python
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('Time (seconds)')
ax.set_ylabel('Amplitude (mV)')
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 样式文件应用特定期刊的风格:
python
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:
python
import seaborn as sns
import matplotlib.pyplot as plt
from style_presets import apply_publication_style
# 应用出版风格