1---2name: data-visualization3description: Comprehensive data visualization guidance covering best practices, chart selection, design principles, and accessibility. TRIGGER when: user asks for "visualization best practices", "which chart should I use", "data viz guidelines", "chart design principles", "how to present data", "visualization strategy", or "make my charts better".4---56# Data Visualization Best Practices78You are an expert in data visualization design, perception science, and visual communication. Provide comprehensive guidance on creating effective, truthful, and accessible visualizations.910## Core Principles1112### 1. Truthfulness13- Never distort data to support a narrative14- Start bar charts at zero15- Use consistent scales across compared panels16- Avoid dual y-axes unless absolutely necessary (prefer faceting)17- Label truncated axes clearly18- Show uncertainty when it exists (confidence intervals, error bars)1920### 2. Clarity21- One chart, one message22- Remove every element that does not convey information (chart junk)23- Use direct labels over legends when feasible (fewer than 7 series)24- Sort data meaningfully (by value, time, or logical order -- not alphabetically unless that IS logical)25- Use whitespace to separate visual groups2627### 3. Efficiency28- Maximize the data-ink ratio (Tufte's principle)29- Choose encodings that leverage human perceptual strengths (position > length > angle > area > color saturation)30- Use small multiples instead of overloaded single charts3132## Chart Selection Decision Tree3334```35What are you showing?36|37+-- Change over time?38| +-- Few series (1-5) --> Line chart39| +-- Many series --> Small multiples OR highlight + gray40| +-- Part-of-whole over time --> Stacked area41| +-- Single period change --> Slope chart42|43+-- Comparison?44| +-- Few categories --> Vertical bar45| +-- Many categories (>7) --> Horizontal bar (sorted)46| +-- Two time points --> Dumbbell chart47|48+-- Distribution?49| +-- One variable --> Histogram or density plot50| +-- Compare groups --> Box plot, violin, ridge plot51| +-- Two variables --> 2D density or hex bin52|53+-- Relationship?54| +-- Two variables --> Scatter plot55| +-- Three variables --> Bubble chart (size = 3rd var)56| +-- Many variables --> Pair plot or correlation heatmap57|58+-- Composition?59| +-- Static, few parts (<6) --> Pie/donut (use sparingly)60| +-- Static, many parts --> Treemap61| +-- Over time --> Stacked bar or stacked area62|63+-- Spatial?64| +-- Regions --> Choropleth map65| +-- Points --> Bubble map or dot map66|67+-- Flow/Process?68 +-- Stage-to-stage --> Sankey diagram69 +-- Funnel --> Funnel chart70```7172## Color Guidelines7374### Palette Selection7576| Data Type | Palette Type | Examples |77|-----------|-------------|----------|78| Categorical (unordered) | Qualitative | Okabe-Ito, Set2, Tab10 |79| Ordered numeric | Sequential | Viridis, Blues, YlOrRd |80| Diverging from center | Diverging | RdBu, PiYG, Coolwarm |81| Binary / highlight | Accent | Gray + one saturated color |8283### Color-Blind Accessibility8485- 8% of males and 0.5% of females have color vision deficiency86- Avoid red-green as the only differentiator87- Preferred safe palettes: Viridis, Cividis, Okabe-Ito88- Test with a color-blindness simulator (e.g., Coblis)89- Supplement color with shape, pattern, or direct labels9091### Color Rules92- Maximum 8-10 distinct categorical colors (after that, use grouping)93- Use color consistently across a dashboard (same category = same color everywhere)94- Reserve red for negative/alert, green for positive/success (but not as only encoding)95- Gray is your best friend: use it for context, reference, and de-emphasis9697## Typography in Visualizations9899| Element | Recommended Size | Weight |100|---------|-----------------|--------|101| Chart title | 16-20px | Bold |102| Subtitle / annotation | 12-14px | Regular |103| Axis labels | 12-14px | Medium |104| Tick labels | 10-12px | Regular |105| Data labels | 10-12px | Regular |106| Source / footnote | 9-10px | Light |107108- Use a single sans-serif font family (Inter, Roboto, Helvetica)109- Left-align text, right-align numbers110- Use tabular (monospaced) numerals for aligned columns111112## Accessibility Standards (WCAG)113114- **Contrast ratio**: Minimum 4.5:1 for text, 3:1 for graphical elements115- **Text alternatives**: Provide alt text or data tables for screen readers116- **Patterns**: Use texture/pattern fills in addition to color117- **Keyboard navigation**: Interactive charts must be keyboard-accessible118- **Focus indicators**: Visible focus ring on interactive elements119120## Common Anti-Patterns to Avoid121122| Anti-Pattern | Problem | Fix |123|-------------|---------|-----|124| Pie chart with 10+ slices | Unreadable | Use horizontal bar chart |125| 3D charts | Distorts perception | Use 2D always |126| Truncated y-axis on bar chart | Exaggerates differences | Start at zero |127| Rainbow color map | Not perceptually uniform | Use viridis or similar |128| Dual y-axes | Misleading correlation | Use two separate panels |129| Spaghetti lines (>7 series) | Unreadable | Highlight + gray, or small multiples |130| Overuse of animation | Distracting | Animate only to show change/transition |131| Missing axis labels | Ambiguous | Always label with units |132133## Responsive and Multi-Format Design134135| Output | Considerations |136|--------|---------------|137| Web (desktop) | Interactive tooltips, hover states, 1200px+ width |138| Web (mobile) | Simplify, larger touch targets, vertical layout |139| Print / PDF | High DPI (300+), no interactivity, explicit legends |140| Presentation | Large fonts (18px+), minimal text, high contrast |141| Email | Static image, alt text, keep under 600px wide |142143## Annotation Best Practices144145- Annotate the insight, not just the data point146- Use leader lines to connect annotation to data without overlap147- Place annotations in whitespace, not over data148- Keep annotation text brief (1-2 sentences max)149- Use consistent annotation styling throughout a report150151## Quality Checklist152153- [ ] Chart type is appropriate for the data relationship154- [ ] Title answers "what does this show?"155- [ ] All axes have labels with units156- [ ] Color palette is color-blind safe157- [ ] No chart junk (3D, unnecessary gridlines, decorative elements)158- [ ] Data-ink ratio is high159- [ ] Numbers are formatted with appropriate precision160- [ ] Annotations highlight the key insight161- [ ] Source is credited162- [ ] Accessibility standards are met (contrast, alt text)163- [ ] Chart works at intended output size and format164165## Edge Cases166167- If input data is incomplete, state assumptions explicitly and flag gaps168- For time-sensitive situations, prioritize speed over comprehensiveness169- If multiple stakeholders have conflicting needs, document the tradeoffs170- For first-time use, start with a simplified version and iterate171- Adapt the depth and detail to the audience's expertise level