data scienceintermediate1120 tokens
Visualization Recommendations
Choose and create effective data visualizations with best practices
data-visualizationmatplotlibseabornchartspythondesign
Prompt Template
You are a data visualization expert. Recommend the best visualizations for this data and analysis goal.
**Data Description:**
{data_description}
**Analysis Goal:**
{goal}
**Audience:**
{audience}
**Constraints:**
- Medium: {medium}
- Tools available: {tools}
- Color accessibility: {color_requirements}
Recommend visualizations following best practices:
**1. Chart Selection Framework:**
For your goal "{goal}", consider:
**Comparison:**
- Few categories (< 7): Bar chart (horizontal if labels long)
- Many categories: Grouped/stacked bar, small multiples
- Two variables: Grouped bar chart
- Part-to-whole: Stacked bar (100%), pie (only if 2-3 categories)
**Distribution:**
- Single variable: Histogram, density plot, box plot
- Multiple groups: Violin plot, ridge plot
- Check normality: Q-Q plot
- Outliers: Box plot with individual points
**Relationship:**
- 2 continuous: Scatter plot, hexbin (if many points)
- 3 continuous: Scatter with size/color encoding, 3D (sparingly)
- With categories: Scatter with color/shape per category
- Trend over time: Line chart
- Correlation matrix: Heatmap
**Composition:**
- Over time: Stacked area chart
- Static: Treemap, sunburst, stacked bar
- Hierarchical: Dendrogram, treemap
**Spatial:**
- Geographic: Choropleth, dot map, heat map
- Network: Node-link diagram, arc diagram
**2. Recommended Visualizations:**
**Primary Visualization:**
- **Chart Type:** {chart_type}
- **Rationale:** Why this chart best shows your data
- **What it reveals:** Key insights visible
- **Encodings:**
- X-axis: {variable} (scale: linear/log/categorical)
- Y-axis: {variable}
- Color: {variable or meaning}
- Size: {variable or fixed}
- Shape: {variable or fixed}
**Code Example:**
```python
import matplotlib.pyplot as plt
import seaborn as sns
# Set style
sns.set_style("whitegrid")
plt.rcParams['figure.figsize'] = (12, 8)
plt.rcParams['font.size'] = 11
# Create visualization
fig, ax = plt.subplots()
# [Specific plot code]
# Styling
ax.set_xlabel('{x_label}', fontsize=12, fontweight='bold')
ax.set_ylabel('{y_label}', fontsize=12, fontweight='bold')
ax.set_title('{title}', fontsize=14, fontweight='bold', pad=20)
# Add annotations if needed
# [Highlight key data points]
# Accessibility
# [Color-blind friendly palette]
plt.tight_layout()
plt.show()
```
**3. Alternative Visualizations:**
**Option 2:** {chart_type_2}
- When to use: {condition}
- Pros: {advantages}
- Cons: {disadvantages}
**Option 3:** {chart_type_3}
- When to use: {condition}
- Pros: {advantages}
- Cons: {disadvantages}
**4. Design Best Practices:**
**Chart Junk Removal:**
- Remove: Gridlines (or make subtle), 3D effects, excessive colors
- Keep: Data, clear labels, meaningful titles
**Color Strategy:**
- Categorical data: Distinct hues (max 7-10 categories)
- Sequential data: Single hue gradient
- Diverging data: Two-hue gradient (use for +/- or above/below)
- Accessibility: Use ColorBrewer palettes or check with contrast checker
**Typography:**
- Title: 14-16pt, bold, describes what to see
- Axis labels: 11-12pt, clear units
- Tick labels: 10-11pt
- Annotations: 10pt, used sparingly
**White Space:**
- Margins: Adequate padding around plot
- Spacing: Between elements, don't crowd
**5. Interactive vs. Static:**
**If Interactive (e.g., Plotly, Altair):**
- Add tooltips: Show exact values on hover
- Zoom/pan: For dense data
- Filters: Let audience explore
- Linked views: Multiple coordinated charts
**If Static (e.g., Matplotlib, Seaborn):**
- Annotations: Label key points directly
- Reference lines: Show benchmarks, averages
- Text: Include summary stats on chart
- Multiple views: Small multiples for comparisons
**6. Accessibility Checklist:**
- [ ] Color-blind safe palette (use shapes + colors)
- [ ] High contrast (text-to-background ratio ≥ 4.5:1)
- [ ] Large enough fonts (≥ 10pt)
- [ ] Alt text describing chart (for screen readers)
- [ ] Data table alternative provided
**7. Storytelling with Data:**
**Chart Title:**
Instead of "Sales by Region" → "Western Region Leads Sales with 40% Market Share"
Make it an insight, not a label.
**Annotations:**
Point out:
- Highest/lowest values
- Trends or inflection points
- Anomalies or outliers
- Comparisons to benchmarks
**Color Emphasis:**
- Gray for context
- Bold color for data you want to highlight
**8. Common Mistakes to Avoid:**
- [ ] Pie charts for > 5 categories
- [ ] 3D charts (distort perception)
- [ ] Dual y-axes (confusing)
- [ ] Truncated y-axis (misleading)
- [ ] Too many colors (rainbow effect)
- [ ] Missing axis labels or units
- [ ] Inconsistent scales across subplots
**9. Full Code Template:**
```python
# Complete, production-ready visualization code
# [Include data loading, processing, and plotting]
```
**10. Interpretation Guide:**
For your audience ({audience}), explain:
- What the chart shows
- How to read it
- Key takeaways
- What action to take
Provide: Chart recommendation + complete code + design rationale.Variables to Replace
{data_description}{goal}{audience}{medium}{tools}{color_requirements}{chart_type}{variable}{x_label}{y_label}{title}{chart_type_2}{condition}{advantages}{disadvantages}{chart_type_3}Pro Tips
Choose chart type based on your data structure and the question you want to answer. Less is more - remove chart junk.
Related Prompts
Need More Prompts?
Explore our full library of 60+ professional AI prompt templates
Browse All Prompts →