npx skills add ...
npx skills add davila7/claude-code-templates --skill scientific-visualization
npx skills add davila7/claude-code-templates --skill scientific-visualization
Create publication figures with matplotlib/seaborn/plotly. Multi-panel layouts, error bars, significance markers, colorblind-safe, export PDF/EPS/TIFF, for journal-ready scientific plots.
Scientific visualization transforms data into clear, accurate figures for publication. Create journal-ready plots with multi-panel layouts, error bars, significance markers, and colorblind-safe palettes. Export as PDF/EPS/TIFF using matplotlib, seaborn, and plotly for manuscripts.
This skill should be used when:
Apply journal-specific styles using the matplotlib style files in assets/:
For statistical plots, use seaborn with publication styling:
Critical requirements (detailed in references/publication_guidelines.md):
Implementation:
Always use colorblind-friendly palettes (detailed in references/color_palettes.md):
Recommended: Okabe-Ito palette (distinguishable by all types of color blindness):
For heatmaps/continuous data:
viridis, plasma, cividisPuOr, RdBu, BrBG instead)jet or rainbow colormapsAlways test figures in grayscale to ensure interpretability.
Font guidelines (detailed in references/publication_guidelines.md):
Implementation:
Journal-specific widths (detailed in references/journal_requirements.md):
Check figure size compliance:
Best practices:
Example implementation (see references/matplotlib_examples.md for complete code):
See references/matplotlib_examples.md Example 1 for complete code.
Key steps:
Using seaborn for automatic confidence intervals:
See references/matplotlib_examples.md Example 2 for complete code.
Key steps:
GridSpec for flexible layoutSee references/matplotlib_examples.md Example 4 for complete code.
Key steps:
viridis, plasma, cividis)RdBu_r, PuOr)Using seaborn for correlation matrices:
Workflow:
references/journal_requirements.mdChecklist approach (full checklist in references/publication_guidelines.md):
Strategy:
assets/color_palettes.pyExample:
Always include:
Example with statistics:
references/matplotlib_examples.md for extensive examplesSeaborn provides a high-level, dataset-oriented interface for statistical graphics, built on matplotlib. It excels at creating publication-quality statistical visualizations with minimal code while maintaining full compatibility with matplotlib customization.
Key advantages for scientific visualization:
Always apply matplotlib publication styles first, then configure seaborn:
Statistical comparisons:
Distribution analysis:
Correlation matrices:
Time series with confidence bands:
Using FacetGrid for automatic faceting:
Combining seaborn with matplotlib subplots:
Seaborn includes several colorblind-safe palettes:
Axes-level functions (e.g., scatterplot, boxplot, heatmap):
ax= parameter for precise placementFigure-level functions (e.g., relplot, catplot, displot):
height and aspect for sizingSeaborn automatically computes and displays uncertainty:
Always set publication theme first:
Use colorblind-safe palettes:
Remove unnecessary elements:
Control figure size appropriately:
Show individual data points when possible:
Include proper labels with units:
Export at correct resolution:
Pairwise relationships for exploratory analysis:
Hierarchical clustering heatmap:
Joint distributions with marginals:
Issue: Legend outside plot area
Issue: Overlapping labels
Issue: Text too small at final size
For more detailed seaborn information, see:
scientific-packages/seaborn/SKILL.md - Comprehensive seaborn documentationscientific-packages/seaborn/references/examples.md - Practical use casesscientific-packages/seaborn/references/function_reference.md - Complete API referencescientific-packages/seaborn/references/objects_interface.md - Modern declarative APILoad these as needed for detailed information:
publication_guidelines.md: Comprehensive best practices
color_palettes.md: Color usage guide
journal_requirements.md: Journal-specific specifications
matplotlib_examples.md: Practical code examples
Use these helper scripts for automation:
figure_export.py: Export utilities
save_publication_figure(): Save in multiple formats with correct DPIsave_for_journal(): Use journal-specific requirements automaticallycheck_figure_size(): Verify dimensions meet journal specspython scripts/figure_export.py for examplesstyle_presets.py: Pre-configured styles
apply_publication_style(): Apply preset styles (default, nature, science, cell)set_color_palette(): Quick palette switchingconfigure_for_journal(): One-command journal configurationpython scripts/style_presets.py to see examplesUse these files in figures:
color_palettes.py: Importable color definitions
apply_palette() helper functionMatplotlib style files: Use with plt.style.use()
publication.mplstyle: General publication qualitynature.mplstyle: Nature journal specificationspresentation.mplstyle: Larger fonts for posters/slidesRecommended workflow for creating publication figures:
Before submitting figures, verify:
Use this skill to ensure scientific figures meet the highest publication standards while remaining accessible to all readers.
import matplotlib.pyplot as plt
# Option 1: Use style file directly
plt.style.use('assets/nature.mplstyle')
# Option 2: Use style_presets.py helper
from style_presets import configure_for_journal
configure_for_journal('nature', figure_width='single')
# Now create figures - they'll automatically match Nature specifications
fig, ax = plt.subplots()
# ... your plotting code ...import seaborn as sns
import matplotlib.pyplot as plt
from style_presets import apply_publication_style
# Apply publication style
apply_publication_style('default')
sns.set_theme(style='ticks', context='paper', font_scale=1.1)
sns.set_palette('colorblind')
# Create statistical comparison figure
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('Response (μM)')
sns.despine()
# Save figure
from figure_export import save_publication_figure
save_publication_figure(fig, 'treatment_comparison', formats=['pdf', 'png'], dpi=300)# Use the figure_export.py script for correct settings
from figure_export import save_publication_figure
# Saves in multiple formats with proper DPI
save_publication_figure(fig, 'myfigure', formats=['pdf', 'png'], dpi=300)
# Or save for specific journal requirements
from figure_export import save_for_journal
save_for_journal(fig, 'figure1', journal='nature', figure_type='combination')# Option 1: Use assets/color_palettes.py
from color_palettes import OKABE_ITO_LIST, apply_palette
apply_palette('okabe_ito')
# Option 2: Manual specification
okabe_ito = ['#E69F00', '#56B4E9', '#009E73', '#F0E442',
'#0072B2', '#D55E00', '#CC79A7', '#000000']
plt.rcParams['axes.prop_cycle'] = plt.cycler(color=okabe_ito)# Set fonts globally
import matplotlib as mpl
mpl.rcParams['font.family'] = 'sans-serif'
mpl.rcParams['font.sans-serif'] = ['Arial', 'Helvetica']
mpl.rcParams['font.size'] = 8
mpl.rcParams['axes.labelsize'] = 9
mpl.rcParams['xtick.labelsize'] = 7
mpl.rcParams['ytick.labelsize'] = 7from figure_export import check_figure_size
fig = plt.figure(figsize=(3.5, 3)) # 89 mm for Nature
check_figure_size(fig, journal='nature')from string import ascii_uppercase
fig = plt.figure(figsize=(7, 4))
gs = fig.add_gridspec(2, 2, hspace=0.4, wspace=0.4)
ax1 = fig.add_subplot(gs[0, 0])
ax2 = fig.add_subplot(gs[0, 1])
# ... create other panels ...
# Add panel labels
for i, ax in enumerate([ax1, ax2, ...]):
ax.text(-0.15, 1.05, ascii_uppercase[i], transform=ax.transAxes,
fontsize=10, fontweight='bold', va='top')import seaborn as sns
fig, ax = plt.subplots(figsize=(5, 3))
sns.lineplot(data=timeseries, x='time', y='measurement',
hue='treatment', errorbar=('ci', 95),
markers=True, ax=ax)
ax.set_xlabel('Time (hours)')
ax.set_ylabel('Measurement (AU)')
sns.despine()import seaborn as sns
fig, ax = plt.subplots(figsize=(5, 4))
corr = df.corr()
mask = np.triu(np.ones_like(corr, dtype=bool))
sns.heatmap(corr, mask=mask, annot=True, fmt='.2f',
cmap='RdBu_r', center=0, square=True,
linewidths=1, cbar_kws={'shrink': 0.8}, ax=ax)