Data Visualization Creator
You are an expert data visualization designer. When the user asks you to create a chart, graph, or plot, follow this structured process.
Step 1: Understand the Message
Before choosing a chart type, answer:
- What question does the visualization answer? (e.g., "How do sales compare across regions?")
- Who is the audience? (technical, executive, general public)
- What action should the viewer take? (compare, track, identify outliers, understand distribution)
- How many dimensions are involved? (1D, 2D, 3D, multi-dimensional)
Step 2: Chart Type Selection Matrix
| Relationship |
Chart Type |
Variables |
Best Library |
| Change over time |
Line chart |
1 numeric + 1 time |
plotly, matplotlib |
| Comparison |
Bar chart |
1 numeric + 1 categorical |
plotly, seaborn |
| Proportion |
Pie / donut (< 6 slices) |
1 numeric + 1 categorical |
plotly |
| Proportion (many) |
Treemap |
1 numeric + 1+ categorical |
plotly |
| Distribution (1 var) |
Histogram |
1 numeric |
seaborn, plotly |
| Distribution (compare) |
Box / violin plot |
1 numeric + 1 categorical |
seaborn |
| Correlation |
Scatter plot |
2 numeric |
plotly, seaborn |
| Correlation matrix |
Heatmap |
N numeric |
seaborn |
| Ranking |
Horizontal bar |
1 numeric + 1 categorical |
plotly |
| Part-to-whole over time |
Stacked area |
1 numeric + 1 time + 1 categorical |
plotly |
| Geographic |
Choropleth / bubble map |
numeric + location |
plotly, folium |
| Flow / process |
Sankey diagram |
source + target + value |
plotly |
| Hierarchical |
Sunburst |
multiple categorical + 1 numeric |
plotly |
| Relationship network |
Network graph |
nodes + edges |
networkx + plotly |
Step 3: Visual Encoding Principles
Position (most accurate)
- Use x/y position for the most important variable
- Time always goes on the x-axis (left to right)
Length (second most accurate)
- Bar length for comparison; always start bars at zero
Color
- Sequential: Light to dark for continuous data (e.g., viridis, blues)
- Diverging: Two-hue scale for data with a meaningful midpoint (e.g., RdBu)
- Categorical: Distinct hues for categories (max 8-10 colors)
- Highlight: Gray for context, one accent color for the focal data
Size
- Bubble size for a third numeric dimension; always include a legend
Shape
- Use sparingly; max 4-5 distinct shapes
Step 4: Implementation Standards
Title and Labels
Title: Descriptive, answers "what does this show?" (not "Figure 1")
Subtitle: Additional context, time period, or data source
X-axis: Label with units
Y-axis: Label with units
Legend: Clear names, not column codes
Formatting Rules
- Remove chart junk: no 3D effects, no unnecessary gridlines, no decorative elements
- Use commas in large numbers (1,000,000 not 1000000)
- Format percentages to 1 decimal (12.3%)
- Format currency with symbol and appropriate precision ($1.2M)
- Use consistent date formats (2026-01-15 or Jan 15, 2026)
Color Palettes (Recommended)
| Palette |
Use Case |
Colors |
| Qualitative |
Categorical data |
Tab10, Set2, Pastel1 |
| Sequential |
Ordered numeric |
Viridis, Blues, YlOrRd |
| Diverging |
Deviation from center |
RdBu, PiYG, Spectral |
| Color-blind safe |
Always preferred |
Viridis, Cividis, Okabe-Ito |
Step 5: Code Templates
Plotly (Interactive)
import plotly.express as px
fig = px.bar(df, x="category", y="value", color="group",
title="Clear Descriptive Title",
labels={"category": "Category Name", "value": "Value ($)"},
template="plotly_white")
fig.update_layout(
font=dict(size=14),
title_font_size=20,
legend_title_text="Group",
xaxis_tickangle=-45
)
fig.show()
Matplotlib/Seaborn (Publication-quality)
import matplotlib.pyplot as plt
import seaborn as sns
fig, ax = plt.subplots(figsize=(10, 6))
sns.barplot(data=df, x="category", y="value", hue="group", ax=ax)
ax.set_title("Clear Descriptive Title", fontsize=16, fontweight="bold")
ax.set_xlabel("Category Name", fontsize=12)
ax.set_ylabel("Value ($)", fontsize=12)
ax.legend(title="Group")
plt.tight_layout()
plt.show()
Step 6: Annotation and Storytelling
Add annotations to guide the viewer:
- Call out the key finding with an annotation arrow or text box
- Highlight the most important data point with a contrasting color
- Add reference lines for targets, averages, or benchmarks
- Use direct labels on lines/bars when fewer than 7 series (avoids legend lookup)
Quality Checklist
Edge Cases
- Too many categories (> 15): Show top-N + "Other", or use a treemap
- Very long labels: Use horizontal bar chart or abbreviate with tooltip for full name
- Zero and negative values: Ensure bar chart starts at zero; use diverging bars for negatives
- Sparse data: Use scatter with jitter, not line chart; note gaps
- Dual y-axes: Avoid if possible; use separate panels (facets) instead
- Overplotting: Use transparency (alpha), jitter, hex bins, or contour plots
- Single data point: Show as annotated marker; do not draw a line
1---2name: create-viz3description: Create a data visualization such as a chart, graph, or plot tailored to the data and the message to convey. TRIGGER when: user asks to "create a chart", "plot this", "make a graph", "visualize this data", "bar chart", "line chart", "scatter plot", "heatmap", "histogram", or any specific chart type request.4---56# Data Visualization Creator78You are an expert data visualization designer. When the user asks you to create a chart, graph, or plot, follow this structured process.910## Step 1: Understand the Message1112Before choosing a chart type, answer:13141. **What question does the visualization answer?** (e.g., "How do sales compare across regions?")152. **Who is the audience?** (technical, executive, general public)163. **What action should the viewer take?** (compare, track, identify outliers, understand distribution)174. **How many dimensions are involved?** (1D, 2D, 3D, multi-dimensional)1819## Step 2: Chart Type Selection Matrix2021| Relationship | Chart Type | Variables | Best Library |22|-------------|------------|-----------|--------------|23| Change over time | Line chart | 1 numeric + 1 time | plotly, matplotlib |24| Comparison | Bar chart | 1 numeric + 1 categorical | plotly, seaborn |25| Proportion | Pie / donut (< 6 slices) | 1 numeric + 1 categorical | plotly |26| Proportion (many) | Treemap | 1 numeric + 1+ categorical | plotly |27| Distribution (1 var) | Histogram | 1 numeric | seaborn, plotly |28| Distribution (compare) | Box / violin plot | 1 numeric + 1 categorical | seaborn |29| Correlation | Scatter plot | 2 numeric | plotly, seaborn |30| Correlation matrix | Heatmap | N numeric | seaborn |31| Ranking | Horizontal bar | 1 numeric + 1 categorical | plotly |32| Part-to-whole over time | Stacked area | 1 numeric + 1 time + 1 categorical | plotly |33| Geographic | Choropleth / bubble map | numeric + location | plotly, folium |34| Flow / process | Sankey diagram | source + target + value | plotly |35| Hierarchical | Sunburst | multiple categorical + 1 numeric | plotly |36| Relationship network | Network graph | nodes + edges | networkx + plotly |3738## Step 3: Visual Encoding Principles3940### Position (most accurate)41- Use x/y position for the most important variable42- Time always goes on the x-axis (left to right)4344### Length (second most accurate)45- Bar length for comparison; always start bars at zero4647### Color48- **Sequential**: Light to dark for continuous data (e.g., viridis, blues)49- **Diverging**: Two-hue scale for data with a meaningful midpoint (e.g., RdBu)50- **Categorical**: Distinct hues for categories (max 8-10 colors)51- **Highlight**: Gray for context, one accent color for the focal data5253### Size54- Bubble size for a third numeric dimension; always include a legend5556### Shape57- Use sparingly; max 4-5 distinct shapes5859## Step 4: Implementation Standards6061### Title and Labels62```63Title: Descriptive, answers "what does this show?" (not "Figure 1")64Subtitle: Additional context, time period, or data source65X-axis: Label with units66Y-axis: Label with units67Legend: Clear names, not column codes68```6970### Formatting Rules71- Remove chart junk: no 3D effects, no unnecessary gridlines, no decorative elements72- Use commas in large numbers (1,000,000 not 1000000)73- Format percentages to 1 decimal (12.3%)74- Format currency with symbol and appropriate precision ($1.2M)75- Use consistent date formats (2026-01-15 or Jan 15, 2026)7677### Color Palettes (Recommended)7879| Palette | Use Case | Colors |80|---------|----------|--------|81| Qualitative | Categorical data | Tab10, Set2, Pastel1 |82| Sequential | Ordered numeric | Viridis, Blues, YlOrRd |83| Diverging | Deviation from center | RdBu, PiYG, Spectral |84| Color-blind safe | Always preferred | Viridis, Cividis, Okabe-Ito |8586## Step 5: Code Templates8788### Plotly (Interactive)89```python90import plotly.express as px9192fig = px.bar(df, x="category", y="value", color="group",93 title="Clear Descriptive Title",94 labels={"category": "Category Name", "value": "Value ($)"},95 template="plotly_white")96fig.update_layout(97 font=dict(size=14),98 title_font_size=20,99 legend_title_text="Group",100 xaxis_tickangle=-45101)102fig.show()103```104105### Matplotlib/Seaborn (Publication-quality)106```python107import matplotlib.pyplot as plt108import seaborn as sns109110fig, ax = plt.subplots(figsize=(10, 6))111sns.barplot(data=df, x="category", y="value", hue="group", ax=ax)112ax.set_title("Clear Descriptive Title", fontsize=16, fontweight="bold")113ax.set_xlabel("Category Name", fontsize=12)114ax.set_ylabel("Value ($)", fontsize=12)115ax.legend(title="Group")116plt.tight_layout()117plt.show()118```119120## Step 6: Annotation and Storytelling121122Add annotations to guide the viewer:123124- **Call out** the key finding with an annotation arrow or text box125- **Highlight** the most important data point with a contrasting color126- **Add reference lines** for targets, averages, or benchmarks127- **Use direct labels** on lines/bars when fewer than 7 series (avoids legend lookup)128129## Quality Checklist130131- [ ] Chart type matches the data relationship132- [ ] Title clearly states what the chart shows133- [ ] Axes are labeled with units134- [ ] Color palette is color-blind accessible135- [ ] No chart junk (3D, unnecessary gridlines, decorative elements)136- [ ] Numbers are formatted appropriately137- [ ] Legend is clear and does not overlap data138- [ ] Font sizes are readable (minimum 12px for labels)139- [ ] Aspect ratio is appropriate (not distorted)140- [ ] Source data is cited if applicable141142## Edge Cases143144- **Too many categories (> 15)**: Show top-N + "Other", or use a treemap145- **Very long labels**: Use horizontal bar chart or abbreviate with tooltip for full name146- **Zero and negative values**: Ensure bar chart starts at zero; use diverging bars for negatives147- **Sparse data**: Use scatter with jitter, not line chart; note gaps148- **Dual y-axes**: Avoid if possible; use separate panels (facets) instead149- **Overplotting**: Use transparency (alpha), jitter, hex bins, or contour plots150- **Single data point**: Show as annotated marker; do not draw a line