home / skills / gptomics / bioskills / figure-export

figure-export skill

/reporting/figure-export

This skill exports publication-ready figures in PDF, SVG, and TIFF with correct resolution, sizing, and typography for journals and presentations.

npx playbooks add skill gptomics/bioskills --skill figure-export

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
3.2 KB
---
name: bio-reporting-figure-export
description: Exports publication-ready figures in various formats with proper resolution, sizing, and typography. Use when preparing figures for journal submission, creating vector graphics for presentations, or ensuring consistent figure styling across analyses.
tool_type: mixed
primary_tool: matplotlib
---

## Version Compatibility

Reference examples tested with: ggplot2 3.5+, matplotlib 3.8+

Before using code patterns, verify installed versions match. If versions differ:
- Python: `pip show <package>` then `help(module.function)` to check signatures
- R: `packageVersion('<pkg>')` then `?function_name` to verify parameters

If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.

# Publication-Ready Figure Export

**"Export figures for publication"** → Save plots as high-resolution PDF/SVG/TIFF with journal-required DPI and dimensions.
- Python: `fig.savefig('fig.pdf', dpi=300, bbox_inches='tight')`
- R: `ggsave('fig.pdf', width=7, height=5, units='in')`

## Python (matplotlib)

```python
import matplotlib.pyplot as plt

# Set publication defaults
plt.rcParams.update({
    'font.size': 8,
    'font.family': 'Arial',
    'axes.linewidth': 0.5,
    'lines.linewidth': 1,
    'figure.dpi': 300
})

fig, ax = plt.subplots(figsize=(3.5, 3))  # Single column width
# ... create plot ...

# Save in multiple formats
fig.savefig('figure1.pdf', bbox_inches='tight', dpi=300)
fig.savefig('figure1.png', bbox_inches='tight', dpi=300)
fig.savefig('figure1.svg', bbox_inches='tight')
```

## R (ggplot2)

```r
library(ggplot2)

p <- ggplot(data, aes(x, y)) + geom_point() +
  theme_classic(base_size = 8) +
  theme(text = element_text(family = 'Arial'))

# PDF for vector graphics
ggsave('figure1.pdf', p, width = 3.5, height = 3, units = 'in')

# High-res PNG
ggsave('figure1.png', p, width = 3.5, height = 3, units = 'in', dpi = 300)

# TIFF (some journals require)
ggsave('figure1.tiff', p, width = 3.5, height = 3, units = 'in',
       dpi = 300, compression = 'lzw')
```

## Journal Requirements

| Journal Type | Format | Resolution | Width |
|--------------|--------|------------|-------|
| Most journals | PDF/EPS | Vector | 3.5" (1-col), 7" (2-col) |
| Online-only | PNG | 300 DPI | Variable |
| Print | TIFF | 300-600 DPI | Column width |

## Multi-panel Figures

```python
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec

fig = plt.figure(figsize=(7, 5))  # Two-column width
gs = GridSpec(2, 3, figure=fig)

ax1 = fig.add_subplot(gs[0, 0])
ax2 = fig.add_subplot(gs[0, 1:])
ax3 = fig.add_subplot(gs[1, :])

# Add panel labels
for ax, label in zip([ax1, ax2, ax3], ['A', 'B', 'C']):
    ax.text(-0.1, 1.1, label, transform=ax.transAxes,
            fontsize=10, fontweight='bold')

fig.savefig('figure_multipanel.pdf', bbox_inches='tight')
```

## Color Considerations

- Use colorblind-friendly palettes (viridis, cividis)
- Ensure sufficient contrast for grayscale printing
- Maintain consistency across all figures

## Related Skills

- data-visualization/ggplot2-fundamentals - Creating plots in R
- data-visualization/heatmaps-clustering - Complex visualizations
- data-visualization/multipanel-figures - Figure composition

Overview

This skill exports publication-ready figures in multiple formats with correct resolution, sizing, and typography. It provides practical patterns for matplotlib (Python) and ggplot2 (R) to produce vector and raster outputs tailored to journal and presentation requirements. The focus is reproducible, consistent styling and multi-panel composition.

How this skill works

The skill supplies code patterns and configuration recommendations to set font, DPI, line widths, and figure dimensions, then save plots as PDF, SVG, PNG, or TIFF. It covers single- and multi-panel layouts, journal column widths, and color choices suited for colorblind readers and grayscale printing. It also recommends version-checking steps and simple diagnostics when APIs differ.

When to use it

  • Preparing figures for journal submission (vector PDFs or TIFFs at required DPI)
  • Creating vector graphics for talks or posters (SVG/PDF for scalability)
  • Producing consistent styling across multiple figures or collaborators
  • Composing multi-panel figures that meet column-width requirements
  • Exporting high-resolution raster images for web or supplementary material

Best practices

  • Set global figure defaults (font family/size, line widths, DPI) before plotting to ensure consistency
  • Match figure width/height to journal column size (e.g., 3.5 in single-column, 7 in two-column) and use inches/units to control final size
  • Export vector formats (PDF/SVG/EPS) for line art and raster (PNG/TIFF) at 300–600 DPI for photographs or print
  • Use bbox_inches='tight' or equivalent to remove extra whitespace; explicitly set compression for TIFF where required
  • Prefer colorblind-friendly palettes (viridis, cividis) and check figures in grayscale for sufficient contrast
  • When code errors occur, inspect installed package versions and adapt function signatures rather than re-running blindly

Example use cases

  • Save a single-column scatter plot as PDF and 300 DPI PNG for journal and online use
  • Compose a three-panel layout for a two-column manuscript and export a vector PDF
  • Generate TIFF files at 600 DPI for print-focused journals requiring high-resolution raster images
  • Produce a consistent set of figures (same fonts, sizes, palette) for a manuscript with multiple authors
  • Export SVGs for slides and edit typography in a vector editor if final tweaks are needed

FAQ

Which format should I choose for submission?

Prefer vector formats (PDF/SVG/EPS) for line art and schematic plots. Use TIFF or high-res PNG for photographic images when journals require raster files at specified DPI.

What DPI should I use for raster exports?

Use 300 DPI for most online and print needs; use 600 DPI for high-detail print requirements or when the journal explicitly requests it.