| name | visual-design-system |
| description | Publication-grade design tokens and utilities for Nature/JACC/NEJM quality graphics. Use when generating charts, infographics, animations, or any visual content that requires medical-journal-grade color palettes, typography, accessibility-validated contrast ratios, and consistent branding. Provides Python token APIs, colorblind-safe palettes, G2 chart templates, AntV infographic templates, Vizzu animation presets, and Manim integration for animated medical explainers. |
Visual Design System
Purpose: Publication-grade design tokens and utilities for Nature/JACC/NEJM quality graphics.
Status: Phase 3.1 In Progress - Manim Animations
Which Tool Should I Use?
Use this decision table to pick the right backend before writing any code:
| Task | Best Tool | Output |
|---|
| Publication figure (bar, line, forest plot) | Plotly or drawsvg | PNG (300 DPI) |
| Infographic card / social slide | Satori or Component Library | PNG, SVG |
| Medical diagram (heart, ECG, flowchart) | drawsvg | PNG, SVG |
| Clinical trial / drug mechanism template | SVG Templates | PNG, SVG |
| Treatment pathway / CONSORT / PRISMA | Architecture Diagrams | PNG |
| Animated mechanism / Kaplan-Meier / ECG | Manim | MP4 |
| Any of the above with a unified Python API | Component Library | PNG, SVG, HTML |
Quick rule: if it's a static publication figure → Plotly/drawsvg; if it's a polished card or social asset → Satori/Component; if it needs motion → Manim.
Publication Figure Workflow (Create → Validate → Export)
For any publication-grade output, follow this validated sequence:
from skills.cardiology.visual_design_system.tokens import (
get_color, get_accessible_pair, validate_contrast, get_contrast_ratio
)
from cardiology_visual_system.scripts.plotly_charts import create_comparison_bars, save_chart
treatment, control = get_accessible_pair("treatment_control")
fig = create_comparison_bars(
categories=["Primary", "Secondary"],
group1_values=[12.3, 8.5],
group2_values=[18.7, 14.2],
group1_name="Treatment",
group2_name="Placebo",
title="Clinical Trial Results"
)
if not validate_contrast(treatment, "#ffffff"):
ratio = get_contrast_ratio(treatment, "#ffffff")
treatment, control = get_accessible_pair("benefit_risk")
save_chart(fig, "results.png")
If validation fails:
| Problem | Cause | Fix |
|---|
validate_contrast returns False | Ratio < 4.5:1 | Swap to a pre-validated pair via get_accessible_pair() |
| Render produces no output | Missing dependency | Run pip install drawsvg cairosvg or pip install diagrams |
| Manim scene not found | Not in catalog | Run python scripts/render_manim.py --list and check scene_catalog.json |
| 300 DPI export looks blurry | Wrong scale | Use scale=4 in fig.write_image() or save_chart(fig, path) |
| Font not applied | System font missing | Tokens fall back to Arial; check tokens.get_font_family("primary") |
Quick Start
from skills.cardiology.visual_design_system.tokens import (
get_tokens,
get_color,
get_accessible_pair,
validate_contrast,
)
navy = get_color("primary.navy")
treatment, control = get_accessible_pair("treatment_control")
is_safe = validate_contrast("#1e3a5f", "#ffffff")
tokens = get_tokens()
palette = tokens.get_color_palette("categorical")
Design Philosophy
This system enforces Nature journal standards for all visual output:
| Standard | Requirement | How We Enforce |
|---|
| Fonts | Helvetica/Arial only | Token system + validation |
| Font sizes | 5-8pt for figures | Pre-defined size scale |
| Contrast | WCAG AA (4.5:1 min) | Automated validation |
| Colorblind | No red-green only | Paul Tol palettes |
| Resolution | 300 DPI minimum | Export presets |
| Shadows | None in figures | Disabled by default |
Token Categories (Overview)
Full token reference: references/color_palettes.md and references/nature_guidelines.md.
Colors
get_color("primary.navy")
get_color("primary.blue")
get_color("primary.teal")
get_color("semantic.success")
get_color("semantic.warning")
get_color("semantic.danger")
get_color("semantic.neutral")
tokens.get_color_palette("categorical")
tokens.get_color_palette("sequential_blue")
tokens.get_color_palette("diverging")
t, c = get_accessible_pair("treatment_control")
b, r = get_accessible_pair("benefit_risk")
i, p = get_accessible_pair("intervention_placebo")
tokens.get_clinical_color("mortality")
tokens.get_clinical_color("hospitalization")
tokens.get_clinical_color("symptom_improvement")
colors = tokens.get_forest_plot_colors()
Typography
tokens.get_font_family("primary")
tokens.get_font_family("monospace")
tokens.get_font_size("figure_elements", "panel_label")
tokens.get_font_size("figure_elements", "axis_title")
tokens.get_font_size("figure_elements", "axis_tick")
tokens.get_font_size("infographic_elements", "headline")
tokens.get_font_size("social_media", "carousel_stat")
Spacing & Strokes
tokens.get_spacing("xs")
tokens.get_spacing("md")
tokens.get_stroke_width("hairline")
tokens.get_stroke_width("thin")
tokens.get_stroke_width("regular")
Validation
CLI
python scripts/token_validator.py
python scripts/token_validator.py --contrast-report
python scripts/token_validator.py --json
Programmatic
from tokens.index import validate_contrast, get_contrast_ratio
validate_contrast("#1e3a5f", "#ffffff")
validate_contrast("#1e3a5f", "#ffffff", level="AAA")
get_contrast_ratio("#1e3a5f", "#ffffff")
Plotly (Phase 1.4)
Standard publication charts with automatic token integration and 300 DPI export.
from cardiology_visual_system.scripts.plotly_charts import (
create_comparison_bars, save_chart,
)
fig = create_comparison_bars(
categories=["Primary", "Secondary"],
group1_values=[12.3, 8.5],
group2_values=[18.7, 14.2],
group1_name="Treatment",
group2_name="Placebo",
title="Clinical Trial Results"
)
save_chart(fig, "results.png")
cd skills/cardiology/cardiology-visual-system/scripts
python plotly_charts.py demo --quality-report
python plotly_charts.py demo --png --output-dir ../outputs
python plotly_charts.py bar -d data.csv -o chart.png
Direct template usage:
from tokens.index import get_plotly_template
import plotly.io as pio
pio.templates["publication"] = get_plotly_template()
fig = px.bar(data, template="publication")
fig.write_image("chart.png", scale=4)
Satori Infographic Pipeline (Phase 1.2)
Generates PNG/SVG infographic cards from structured data via a Node.js renderer.
Templates: stat-card, comparison, process-flow, trial-summary, key-finding
cd satori/
node renderer.js --list
node renderer.js --template stat-card \
--data '{"value": "26%", "label": "Mortality Reduction", "source": "PARADIGM-HF"}' \
-o ../outputs/stat-card.png
from scripts.generate_infographic import generate_stat_card, generate_trial_summary
generate_stat_card(
"26%", "Mortality Reduction",
sublabel="HR 0.74, 95% CI 0.65-0.85",
source="PARADIGM-HF",
output="outputs/stat-card.png"
)
generate_trial_summary(
"DAPA-HF", "HFrEF patients", "Dapagliflozin 10mg",
"CV death or HF hospitalization",
0.74, "0.65-0.85", "<0.001",
nnt=21,
output="outputs/trial.png"
)
Output: 1200×630px PNG at 2x scale. Custom dimensions: pass width= / height= to any generator or --width/--height to the CLI.
drawsvg Pipeline (Phase 1.3)
Pure Python SVG for medical diagrams and charts. No Node.js required.
pip install drawsvg cairosvg
Modules: medical_diagrams (heart, ECG, conduction, organ icons), data_charts (bar, grouped bar, line, forest plot), process_flows (algorithm, patient journey, study flow, simple flow).
from drawsvg.medical_diagrams import ecg_wave
from drawsvg.data_charts import forest_plot
from drawsvg.process_flows import study_flow
svg = ecg_wave(wave_type="normal", show_labels=True, title="Normal Sinus Rhythm")
svg.save_png("ecg.png")
studies = [
{"name": "DAPA-HF", "estimate": 0.74, "lower": 0.65, "upper": 0.85, "weight": 60},
{"name": "EMPEROR-Reduced", "estimate": 0.75, "lower": 0.65, "upper": 0.86, "weight": 50},
{"name": "DELIVER", "estimate": 0.82, "lower": 0.73, "upper": 0.92, "weight": 70},
]
svg = forest_plot(studies=studies, title="SGLT2 Inhibitors in HF", show_pooled=True)
svg.save_png("forest_plot.png")
svg = study_flow(enrollment=1500, randomized=1200,
groups=[
{"name": "Treatment", "allocated": 600, "discontinued": 45, "analyzed": 555},
{"name": "Control", "allocated": 600, "discontinued": 52, "analyzed": 548},
],
title="DAPA-HF Study Flow"
)
svg.save_png("study_flow.png")
For full parameter reference (all wave_type values, highlight_chamber options, etc.) see svg_diagrams/.
Component Library (Phase 2.1)
Unified Python API wrapping Satori, Plotly, and drawsvg with consistent interfaces.
Components: StatCard, ComparisonChart, ForestPlot, Timeline, ProcessFlow, DataTable
from components import StatCard, ForestPlot, ComparisonChart, DataTable
card = StatCard(value="26%", label="Mortality Reduction",
sublabel="HR 0.74, 95% CI 0.65-0.85", source="PARADIGM-HF")
card.render("stat_card.png")
card.render("stat_card.png", backend="satori")
card.render("stat_card.png", backend="drawsvg")
plot = ForestPlot(studies=[...], title="SGLT2i in HF", x_label="Hazard Ratio (95% CI)")
plot.render("forest.png", backend="plotly")
table = DataTable(
title="Baseline Characteristics",
headers=["Characteristic", "Treatment (n=500)", "Control (n=500)", "P-value"],
rows=[["Age, years", "65.2 ± 12.1", "64.8 ± 11.9", "0.62"]],
footer="Values are mean ± SD or n (%)"
)
table.render("baseline.png")
Backend selection:
| Backend | Best For |
|---|
satori | Infographic cards, social media |
plotly | Interactive charts, data viz |
drawsvg | Publication figures, diagrams |
Resolution config:
from components.base import RenderConfig
config = RenderConfig(width=1200, height=630, quality="print")
card = StatCard(value="42%", label="Test", config=config)
SVG Infographic Templates (Phase 2.2)
lxml-based SVG placeholder replacement for five standard medical layouts.
Templates: trial_results, drug_mechanism, patient_stats, before_after, risk_factors
Full field reference: see TEMPLATE_REFERENCE.md in svglue_templates/.
cd svglue_templates/
python template_renderer.py --list
python template_renderer.py trial_results --demo -o output.svg
python template_renderer.py trial_results --demo --png --scale 2 -o output.svg
from svglue_templates.template_renderer import render_template, save_svg, save_png
from pathlib import Path
svg = render_template("trial_results", {
"trial_name": "PARADIGM-HF",
"primary_hr": "0.80",
"primary_ci": "95% CI: 0.73-0.87",
"primary_p": "P < 0.001",
"source": "McMurray JJV et al. N Engl J Med. 2014",
})
save_svg(svg, Path("trial_results.svg"))
save_png(svg, Path("trial_results.svg"), scale=2)
Architecture Diagrams (Phase 2.3)
Publication-grade clinical pathways and research flow diagrams using mingrammer/diagrams.
pip install diagrams
brew install graphviz
Modules: treatment_pathways (HF, ACS, AF algorithms), research_flows (CONSORT, PRISMA, methodology), healthcare_arch (hospital system, cardiology dept, data pipeline).
from arch_diagrams.treatment_pathways import create_heart_failure_pathway
from arch_diagrams.research_flows import create_consort_diagram
create_heart_failure_pathway(output_path="outputs/hf_pathway", format="png")
create_consort_diagram(
enrolled=500, randomized=400,
treatment_n=200, control_n=200,
treatment_completed=180, control_completed=175,
treatment_analyzed=200, control_analyzed=200,
output_path="outputs/consort", format="png"
)
Diagram color coding:
| Element | Color | Meaning |
|---|
| Assessment | Blue (#2d6a9f) | Diagnostics |
| Decision | Orange (#e65100) | Stratification |
| Treatment | Green (#2e7d32) | Active therapy |
| Danger/Critical | Red (#c62828) | ICU, exclusions |
python arch_diagrams/treatment_pathways.py
python arch_diagrams/research_flows.py
python arch_diagrams/healthcare_arch.py
Manim Animations (Phase 3.1)
Educational animations for mechanisms, survival curves, and ECG fundamentals.
python -m venv .venv-manim
.venv-manim/bin/python -m pip install manim
Key scenes:
| Key | Scene Class | Description |
|---|
mechanism | MechanismOfActionScene | 4-step mechanism flow with outcome callout |
kaplan_meier | KaplanMeierScene | Stepwise survival curves + HR label |
ecg_wave | ECGWaveScene | Normal sinus rhythm with labels |
Full catalog: manim_animations/scene_catalog.json — categories include cardiometabolic, ACS/CAD, arrhythmia, imaging/DX, statistics, devices, anatomy.
cd skills/cardiology/visual-design-system
python scripts/render_manim.py --list
python scripts/render_manim.py mechanism --quality m --format mp4
python scripts/render_manim.py kaplan_meier --quality h --preview
python scripts/render_manim.py ecg_wave --quality l --manim-bin .venv-manim
- Outputs →
outputs/manim/
- Colors and fonts sourced from design tokens via
manim_animations/theme.py
- Carousel slides with
animation_scene route to Manim via carousel-generator-v2
Directory Structure
visual-design-system/
├── SKILL.md
├── tokens/
│ ├── index.py # Main token loader
│ ├── colors.json
│ ├── typography.json
│ ├── spacing.json
│ └── shadows.json
├── scripts/
│ ├── token_validator.py
│ ├── generate_infographic.py
│ └── render_manim.py
├── satori/ # Phase 1.2 - React → SVG → PNG
├── svg_diagrams/ # Phase 1.3 - Pure Python SVG
├── components/ # Phase 2.1 - Component Library
├── svglue_templates/ # Phase 2.2 - SVG Templates
│ └── TEMPLATE_REFERENCE.md # Full field docs for all 5 templates
├── arch_diagrams/ # Phase 2.3 - Architecture Diagrams
├── manim_animations/ # Phase 3.1 - Manim scenes + catalog
├── references/
│ ├── nature_guidelines.md
│ └── color_palettes.md
└── outputs/
References
Last Updated: 2026-01-01
Maintainer: Dr. Shailesh Singh