figure-legend-gen
npx machina-cli add skill aipoch/medical-research-skills/figure-legend-gen --openclawFigure Legend Generator
Generate publication-quality figure legends for scientific research charts and images.
Supported Chart Types
| Chart Type | Description |
|---|---|
| Bar Chart | Compare values across categories |
| Line Graph | Show trends over time or continuous data |
| Scatter Plot | Display relationships between variables |
| Box Plot | Show distribution and outliers |
| Heatmap | Display matrix data intensity |
| Microscopy | Fluorescence/confocal images |
| Flow Cytometry | FACS plots and histograms |
| Western Blot | Protein expression bands |
Usage
python scripts/main.py --input <image_path> --type <chart_type> [--output <output_path>]
Parameters
| Parameter | Required | Description |
|---|---|---|
--input | Yes | Path to chart image |
--type | Yes | Chart type (bar/line/scatter/box/heatmap/microscopy/flow/western) |
--output | No | Output path for legend text (default: stdout) |
--format | No | Output format (text/markdown/latex), default: markdown |
--language | No | Language (en/zh), default: en |
Examples
# Generate legend for bar chart
python scripts/main.py --input figure1.png --type bar
# Save to file
python scripts/main.py --input plot.jpg --type line --output legend.md
# Chinese output
python scripts/main.py --image.png --type scatter --language zh
Legend Structure
Generated legends follow academic standards:
- Figure Number - Sequential numbering
- Brief Title - Concise description
- Main Description - What the figure shows
- Data Details - Key statistics/measurements
- Methodology - Brief experimental context
- Statistics - P-values, significance markers
- Scale Bars - For microscopy images
Technical Notes
- Difficulty: Low
- Dependencies: PIL, pytesseract (optional OCR)
- Processing: Vision analysis for chart type detection
- Output: Structured markdown by default
References
references/legend_templates.md- Templates by chart typereferences/academic_style_guide.md- Formatting guidelines
Risk Assessment
| Risk Indicator | Assessment | Level |
|---|---|---|
| Code Execution | Python scripts with tools | High |
| Network Access | External API calls | High |
| File System Access | Read/write data | Medium |
| Instruction Tampering | Standard prompt guidelines | Low |
| Data Exposure | Data handled securely | Medium |
Security Checklist
- No hardcoded credentials or API keys
- No unauthorized file system access (../)
- Output does not expose sensitive information
- Prompt injection protections in place
- API requests use HTTPS only
- Input validated against allowed patterns
- API timeout and retry mechanisms implemented
- Output directory restricted to workspace
- Script execution in sandboxed environment
- Error messages sanitized (no internal paths exposed)
- Dependencies audited
- No exposure of internal service architecture
Prerequisites
# Python dependencies
pip install -r requirements.txt
Evaluation Criteria
Success Metrics
- Successfully executes main functionality
- Output meets quality standards
- Handles edge cases gracefully
- Performance is acceptable
Test Cases
- Basic Functionality: Standard input → Expected output
- Edge Case: Invalid input → Graceful error handling
- Performance: Large dataset → Acceptable processing time
Lifecycle Status
- Current Stage: Draft
- Next Review Date: 2026-03-06
- Known Issues: None
- Planned Improvements:
- Performance optimization
- Additional feature support
Source
git clone https://github.com/aipoch/medical-research-skills/blob/main/scientific-skills/Academic writing/figure-legend-gen/SKILL.mdView on GitHub Overview
Figure-legend-gen creates publication-quality captions for scientific charts and images from an input figure and specified chart type. It supports bar charts, line graphs, scatter plots, box plots, heatmaps, microscopy images, flow cytometry, and Western blots, and outputs text legends (not visualizations) in a consistent, publication-ready structure.
How This Skill Works
The tool uses vision analysis to detect the chart type from the input image and assembles a legend in a seven-section structure: Figure Number, Brief Title, Main Description, Data Details, Methodology, Statistics, and Scale Bars. Output is structured markdown by default, with optional format and language settings; it relies on PIL and can use pytesseract for OCR when needed.
When to Use It
- Preparing manuscript figure legends for a submitted or published paper.
- Standardizing captions across a batch of related figures in a study.
- Captioning microscopy images with scale bars and fluorescence details.
- Documenting flow cytometry plots or Western blots with statistics.
- Generating language-adapted legends for multilingual manuscripts.
Quick Start
- Step 1: Run the tool with --input <image_path> --type <chart_type>.
- Step 2: (Optional) Specify --output, --format, and --language as needed.
- Step 3: Paste or save the generated legend and integrate into your manuscript.
Best Practices
- Provide a high-resolution input image of the chart or figure.
- Select the correct chart type (--type) to improve legend accuracy.
- Review Data Details and Statistics sections for accuracy and include key metrics.
- Keep the legend self-contained with sufficient context for readers.
- Use the Legend Structure checklist (Figure Number, Brief Title, Main Description, Data Details, Methodology, Statistics, Scale Bars) when editing.
Example Use Cases
- Bar chart comparing patient groups in a clinical trial.
- Heatmap showing gene expression across samples.
- Fluorescence microscopy image with a scale bar and nuclei staining.
- Flow cytometry histogram illustrating marker distribution.
- Western blot panel with protein bands and quantified intensities.
Frequently Asked Questions
Related Skills
dei-statement-drafter
aipoch/medical-research-skills
Draft Diversity, Equity, and Inclusion statements for academic applications
funding-trend-forecaster
aipoch/medical-research-skills
Predict funding trend shifts using NLP analysis of grant abstracts from
figure-reference-checker
aipoch/medical-research-skills
Check figure references in manuscripts
discussion-section-architect
aipoch/medical-research-skills
Guided framework for structuring academic Discussion sections
conflict-of-interest-checker
aipoch/medical-research-skills
Check for co-authorship conflicts between authors and suggested reviewers
conference-poster-pitch
aipoch/medical-research-skills
Generate elevator pitch for conference posters