Skill Tracer
Skills › Knowledge Work Plugins › data-visualization

data-visualization

skill · 305 lines · Apache-2.0 · data/skills/data-visualization/SKILL.md

The facts

Its description

Create effective data visualizations with Python (matplotlib, seaborn, plotly). Use when building charts, choosing the right chart type for a dataset, creating publication-quality figures, or applying design principles like accessibility and color theory.

The description the agent reads to decide when to use it.

From its settingsline 3

When it starts

This skill is marked `user-invocable: false`, so it is not chosen from something a person says; it is loaded by another skill that needs chart-selection guidance, Python plotting patterns, or accessibility rules while it builds a visualization. Nothing in the body points the agent at any other skill, so it reads as a self-contained reference.

A model's summary of when it is used.

A model's reading

Who can start it

Only the agent

Only the agent starts it. It's hidden from your commands.

From its settingsline 4

What leads to it

Other skills that hand off to this one, call it, require it or offer it instead, as a model read them.

A model's reading

Licence

Apache-2.0, from data/LICENSE

The terms its author shares it under, which let it be shown here.

From the repositorylicence text

The text

Open on GitHub
1---
2name: data-visualization
3description: Create effective data visualizations with Python (matplotlib, seaborn, plotly). Use when building charts, choosing the right chart type for a dataset, creating publication-quality figures, or applying design principles like accessibility and color theory.
4user-invocable: false
5---
6
7# Data Visualization Skill
8
9Chart selection guidance, Python visualization code patterns, design principles, and accessibility considerations for creating effective data visualizations.

Data Visualization Skill

Chart selection guidance, Python visualization code patterns, design principles, and accessibility considerations for creating effective data visualizations.

Raw lines 1 to 10
11## Chart Selection Guide

Chart Selection Guide

Raw lines 11 to 12
13### Choose by Data Relationship
15| What You're Showing | Best Chart | Alternatives |
16|---|---|---|
17| **Trend over time** | Line chart | Area chart (if showing cumulative or composition) |
18| **Comparison across categories** | Vertical bar chart | Horizontal bar (many categories), lollipop chart |
19| **Ranking** | Horizontal bar chart | Dot plot, slope chart (comparing two periods) |
20| **Part-to-whole composition** | Stacked bar chart | Treemap (hierarchical), waffle chart |
21| **Composition over time** | Stacked area chart | 100% stacked bar (for proportion focus) |
22| **Distribution** | Histogram | Box plot (comparing groups), violin plot, strip plot |
23| **Correlation (2 variables)** | Scatter plot | Bubble chart (add 3rd variable as size) |
24| **Correlation (many variables)** | Heatmap (correlation matrix) | Pair plot |
25| **Geographic patterns** | Choropleth map | Bubble map, hex map |
26| **Flow / process** | Sankey diagram | Funnel chart (sequential stages) |
27| **Relationship network** | Network graph | Chord diagram |
28| **Performance vs. target** | Bullet chart | Gauge (single KPI only) |
29| **Multiple KPIs at once** | Small multiples | Dashboard with separate charts |

Choose by Data Relationship

What You're ShowingBest ChartAlternatives
Trend over timeLine chartArea chart (if showing cumulative or composition)
Comparison across categoriesVertical bar chartHorizontal bar (many categories), lollipop chart
RankingHorizontal bar chartDot plot, slope chart (comparing two periods)
Part-to-whole compositionStacked bar chartTreemap (hierarchical), waffle chart
Composition over timeStacked area chart100% stacked bar (for proportion focus)
DistributionHistogramBox plot (comparing groups), violin plot, strip plot
Correlation (2 variables)Scatter plotBubble chart (add 3rd variable as size)
Correlation (many variables)Heatmap (correlation matrix)Pair plot
Geographic patternsChoropleth mapBubble map, hex map
Flow / processSankey diagramFunnel chart (sequential stages)
Relationship networkNetwork graphChord diagram
Performance vs. targetBullet chartGauge (single KPI only)
Multiple KPIs at onceSmall multiplesDashboard with separate charts
Raw lines 13 to 30
31### When NOT to Use Certain Charts
33- **Pie charts**: Avoid unless <6 categories and exact proportions matter less than rough comparison. Humans are bad at comparing angles. Use bar charts instead.
34- **3D charts**: Never. They distort perception and add no information.
35- **Dual-axis charts**: Use cautiously. They can mislead by implying correlation. Clearly label both axes if used.
36- **Stacked bar (many categories)**: Hard to compare middle segments. Use small multiples or grouped bars instead.
37- **Donut charts**: Slightly better than pie charts but same fundamental issues. Use for single KPI display at most.

When NOT to Use Certain Charts

  • Pie charts: Avoid unless <6 categories and exact proportions matter less than rough comparison. Humans are bad at comparing angles. Use bar charts instead.
  • 3D charts: Never. They distort perception and add no information.
  • Dual-axis charts: Use cautiously. They can mislead by implying correlation. Clearly label both axes if used.
  • Stacked bar (many categories): Hard to compare middle segments. Use small multiples or grouped bars instead.
  • Donut charts: Slightly better than pie charts but same fundamental issues. Use for single KPI display at most.
Raw lines 31 to 38
39## Python Visualization Code Patterns

Python Visualization Code Patterns

Raw lines 39 to 40
41### Setup and Style
43```python
44import matplotlib.pyplot as plt
45import matplotlib.ticker as mticker
46import seaborn as sns
47import pandas as pd
48import numpy as np
50# Professional style setup
51plt.style.use('seaborn-v0_8-whitegrid')
52plt.rcParams.update({
53 'figure.figsize': (10, 6),
54 'figure.dpi': 150,
55 'font.size': 11,
56 'axes.titlesize': 14,
57 'axes.titleweight': 'bold',
58 'axes.labelsize': 11,
59 'xtick.labelsize': 10,
60 'ytick.labelsize': 10,
61 'legend.fontsize': 10,
62 'figure.titlesize': 16,
63})
65# Colorblind-friendly palettes
66PALETTE_CATEGORICAL = ['#4C72B0', '#DD8452', '#55A868', '#C44E52', '#8172B3', '#937860']
67PALETTE_SEQUENTIAL = 'YlOrRd'
68PALETTE_DIVERGING = 'RdBu_r'
69```

Setup and Style

import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import seaborn as sns
import pandas as pd
import numpy as np

# Professional style setup
plt.style.use('seaborn-v0_8-whitegrid')
plt.rcParams.update({
    'figure.figsize': (10, 6),
    'figure.dpi': 150,
    'font.size': 11,
    'axes.titlesize': 14,
    'axes.titleweight': 'bold',
    'axes.labelsize': 11,
    'xtick.labelsize': 10,
    'ytick.labelsize': 10,
    'legend.fontsize': 10,
    'figure.titlesize': 16,
})

# Colorblind-friendly palettes
PALETTE_CATEGORICAL = ['#4C72B0', '#DD8452', '#55A868', '#C44E52', '#8172B3', '#937860']
PALETTE_SEQUENTIAL = 'YlOrRd'
PALETTE_DIVERGING = 'RdBu_r'
Raw lines 41 to 70
71### Line Chart (Time Series)
73```python
74fig, ax = plt.subplots(figsize=(10, 6))
76for label, group in df.groupby('category'):
77 ax.plot(group['date'], group['value'], label=label, linewidth=2)
79ax.set_title('Metric Trend by Category', fontweight='bold')
80ax.set_xlabel('Date')
81ax.set_ylabel('Value')
82ax.legend(loc='upper left', frameon=True)
83ax.spines['top'].set_visible(False)
84ax.spines['right'].set_visible(False)
86# Format dates on x-axis
87fig.autofmt_xdate()
89plt.tight_layout()
90plt.savefig('trend_chart.png', dpi=150, bbox_inches='tight')
91```

Line Chart (Time Series)

fig, ax = plt.subplots(figsize=(10, 6))

for label, group in df.groupby('category'):
    ax.plot(group['date'], group['value'], label=label, linewidth=2)

ax.set_title('Metric Trend by Category', fontweight='bold')
ax.set_xlabel('Date')
ax.set_ylabel('Value')
ax.legend(loc='upper left', frameon=True)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

# Format dates on x-axis
fig.autofmt_xdate()

plt.tight_layout()
plt.savefig('trend_chart.png', dpi=150, bbox_inches='tight')
Raw lines 71 to 92
93### Bar Chart (Comparison)
95```python
96fig, ax = plt.subplots(figsize=(10, 6))
98# Sort by value for easy reading
99df_sorted = df.sort_values('metric', ascending=True)
101bars = ax.barh(df_sorted['category'], df_sorted['metric'], color=PALETTE_CATEGORICAL[0])
103# Add value labels
104for bar in bars:
105 width = bar.get_width()
106 ax.text(width + 0.5, bar.get_y() + bar.get_height()/2,
107 f'{width:,.0f}', ha='left', va='center', fontsize=10)
109ax.set_title('Metric by Category (Ranked)', fontweight='bold')
110ax.set_xlabel('Metric Value')
111ax.spines['top'].set_visible(False)
112ax.spines['right'].set_visible(False)
114plt.tight_layout()
115plt.savefig('bar_chart.png', dpi=150, bbox_inches='tight')
116```

Bar Chart (Comparison)

fig, ax = plt.subplots(figsize=(10, 6))

# Sort by value for easy reading
df_sorted = df.sort_values('metric', ascending=True)

bars = ax.barh(df_sorted['category'], df_sorted['metric'], color=PALETTE_CATEGORICAL[0])

# Add value labels
for bar in bars:
    width = bar.get_width()
    ax.text(width + 0.5, bar.get_y() + bar.get_height()/2,
            f'{width:,.0f}', ha='left', va='center', fontsize=10)

ax.set_title('Metric by Category (Ranked)', fontweight='bold')
ax.set_xlabel('Metric Value')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

plt.tight_layout()
plt.savefig('bar_chart.png', dpi=150, bbox_inches='tight')
Raw lines 93 to 117
118### Histogram (Distribution)
120```python
121fig, ax = plt.subplots(figsize=(10, 6))
123ax.hist(df['value'], bins=30, color=PALETTE_CATEGORICAL[0], edgecolor='white', alpha=0.8)
125# Add mean and median lines
126mean_val = df['value'].mean()
127median_val = df['value'].median()
128ax.axvline(mean_val, color='red', linestyle='--', linewidth=1.5, label=f'Mean: {mean_val:,.1f}')
129ax.axvline(median_val, color='green', linestyle='--', linewidth=1.5, label=f'Median: {median_val:,.1f}')
131ax.set_title('Distribution of Values', fontweight='bold')
132ax.set_xlabel('Value')
133ax.set_ylabel('Frequency')
134ax.legend()
135ax.spines['top'].set_visible(False)
136ax.spines['right'].set_visible(False)
138plt.tight_layout()
139plt.savefig('histogram.png', dpi=150, bbox_inches='tight')
140```

Histogram (Distribution)

fig, ax = plt.subplots(figsize=(10, 6))

ax.hist(df['value'], bins=30, color=PALETTE_CATEGORICAL[0], edgecolor='white', alpha=0.8)

# Add mean and median lines
mean_val = df['value'].mean()
median_val = df['value'].median()
ax.axvline(mean_val, color='red', linestyle='--', linewidth=1.5, label=f'Mean: {mean_val:,.1f}')
ax.axvline(median_val, color='green', linestyle='--', linewidth=1.5, label=f'Median: {median_val:,.1f}')

ax.set_title('Distribution of Values', fontweight='bold')
ax.set_xlabel('Value')
ax.set_ylabel('Frequency')
ax.legend()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

plt.tight_layout()
plt.savefig('histogram.png', dpi=150, bbox_inches='tight')
Raw lines 118 to 141
142### Heatmap
144```python
145fig, ax = plt.subplots(figsize=(10, 8))
147# Pivot data for heatmap format
148pivot = df.pivot_table(index='row_dim', columns='col_dim', values='metric', aggfunc='sum')
150sns.heatmap(pivot, annot=True, fmt=',.0f', cmap='YlOrRd',
151 linewidths=0.5, ax=ax, cbar_kws={'label': 'Metric Value'})
153ax.set_title('Metric by Row Dimension and Column Dimension', fontweight='bold')
154ax.set_xlabel('Column Dimension')
155ax.set_ylabel('Row Dimension')
157plt.tight_layout()
158plt.savefig('heatmap.png', dpi=150, bbox_inches='tight')
159```

Heatmap

fig, ax = plt.subplots(figsize=(10, 8))

# Pivot data for heatmap format
pivot = df.pivot_table(index='row_dim', columns='col_dim', values='metric', aggfunc='sum')

sns.heatmap(pivot, annot=True, fmt=',.0f', cmap='YlOrRd',
            linewidths=0.5, ax=ax, cbar_kws={'label': 'Metric Value'})

ax.set_title('Metric by Row Dimension and Column Dimension', fontweight='bold')
ax.set_xlabel('Column Dimension')
ax.set_ylabel('Row Dimension')

plt.tight_layout()
plt.savefig('heatmap.png', dpi=150, bbox_inches='tight')
Raw lines 142 to 160
161### Small Multiples
163```python
164categories = df['category'].unique()
165n_cats = len(categories)
166n_cols = min(3, n_cats)
167n_rows = (n_cats + n_cols - 1) // n_cols
169fig, axes = plt.subplots(n_rows, n_cols, figsize=(5*n_cols, 4*n_rows), sharex=True, sharey=True)
170axes = axes.flatten() if n_cats > 1 else [axes]
172for i, cat in enumerate(categories):
173 ax = axes[i]
174 subset = df[df['category'] == cat]
175 ax.plot(subset['date'], subset['value'], color=PALETTE_CATEGORICAL[i % len(PALETTE_CATEGORICAL)])
176 ax.set_title(cat, fontsize=12)
177 ax.spines['top'].set_visible(False)
178 ax.spines['right'].set_visible(False)
180# Hide empty subplots
181for j in range(i+1, len(axes)):
182 axes[j].set_visible(False)
184fig.suptitle('Trends by Category', fontsize=14, fontweight='bold', y=1.02)
185plt.tight_layout()
186plt.savefig('small_multiples.png', dpi=150, bbox_inches='tight')
187```

Small Multiples

categories = df['category'].unique()
n_cats = len(categories)
n_cols = min(3, n_cats)
n_rows = (n_cats + n_cols - 1) // n_cols

fig, axes = plt.subplots(n_rows, n_cols, figsize=(5*n_cols, 4*n_rows), sharex=True, sharey=True)
axes = axes.flatten() if n_cats > 1 else [axes]

for i, cat in enumerate(categories):
    ax = axes[i]
    subset = df[df['category'] == cat]
    ax.plot(subset['date'], subset['value'], color=PALETTE_CATEGORICAL[i % len(PALETTE_CATEGORICAL)])
    ax.set_title(cat, fontsize=12)
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)

# Hide empty subplots
for j in range(i+1, len(axes)):
    axes[j].set_visible(False)

fig.suptitle('Trends by Category', fontsize=14, fontweight='bold', y=1.02)
plt.tight_layout()
plt.savefig('small_multiples.png', dpi=150, bbox_inches='tight')
Raw lines 161 to 188
189### Number Formatting Helpers
191```python
192def format_number(val, format_type='number'):
193 """Format numbers for chart labels."""
194 if format_type == 'currency':
195 if abs(val) >= 1e9:
196 return f'${val/1e9:.1f}B'
197 elif abs(val) >= 1e6:
198 return f'${val/1e6:.1f}M'
199 elif abs(val) >= 1e3:
200 return f'${val/1e3:.1f}K'
201 else:
202 return f'${val:,.0f}'
203 elif format_type == 'percent':
204 return f'{val:.1f}%'
205 elif format_type == 'number':
206 if abs(val) >= 1e9:
207 return f'{val/1e9:.1f}B'
208 elif abs(val) >= 1e6:
209 return f'{val/1e6:.1f}M'
210 elif abs(val) >= 1e3:
211 return f'{val/1e3:.1f}K'
212 else:
213 return f'{val:,.0f}'
214 return str(val)
216# Usage with axis formatter
217ax.yaxis.set_major_formatter(mticker.FuncFormatter(lambda x, p: format_number(x, 'currency')))
218```

Number Formatting Helpers

def format_number(val, format_type='number'):
    """Format numbers for chart labels."""
    if format_type == 'currency':
        if abs(val) >= 1e9:
            return f'${val/1e9:.1f}B'
        elif abs(val) >= 1e6:
            return f'${val/1e6:.1f}M'
        elif abs(val) >= 1e3:
            return f'${val/1e3:.1f}K'
        else:
            return f'${val:,.0f}'
    elif format_type == 'percent':
        return f'{val:.1f}%'
    elif format_type == 'number':
        if abs(val) >= 1e9:
            return f'{val/1e9:.1f}B'
        elif abs(val) >= 1e6:
            return f'{val/1e6:.1f}M'
        elif abs(val) >= 1e3:
            return f'{val/1e3:.1f}K'
        else:
            return f'{val:,.0f}'
    return str(val)

# Usage with axis formatter
ax.yaxis.set_major_formatter(mticker.FuncFormatter(lambda x, p: format_number(x, 'currency')))
Raw lines 189 to 219
220### Interactive Charts with Plotly
222```python
223import plotly.express as px
224import plotly.graph_objects as go
226# Simple interactive line chart
227fig = px.line(df, x='date', y='value', color='category',
228 title='Interactive Metric Trend',
229 labels={'value': 'Metric Value', 'date': 'Date'})
230fig.update_layout(hovermode='x unified')
231fig.write_html('interactive_chart.html')
232fig.show()
234# Interactive scatter with hover data
235fig = px.scatter(df, x='metric_a', y='metric_b', color='category',
236 size='size_metric', hover_data=['name', 'detail_field'],
237 title='Correlation Analysis')
238fig.show()
239```

Interactive Charts with Plotly

import plotly.express as px
import plotly.graph_objects as go

# Simple interactive line chart
fig = px.line(df, x='date', y='value', color='category',
              title='Interactive Metric Trend',
              labels={'value': 'Metric Value', 'date': 'Date'})
fig.update_layout(hovermode='x unified')
fig.write_html('interactive_chart.html')
fig.show()

# Interactive scatter with hover data
fig = px.scatter(df, x='metric_a', y='metric_b', color='category',
                 size='size_metric', hover_data=['name', 'detail_field'],
                 title='Correlation Analysis')
fig.show()
Raw lines 220 to 240
241## Design Principles

Design Principles

Raw lines 241 to 242
243### Color
245- **Use color purposefully**: Color should encode data, not decorate
246- **Highlight the story**: Use a bright accent color for the key insight; grey everything else
247- **Sequential data**: Use a single-hue gradient (light to dark) for ordered values
248- **Diverging data**: Use a two-hue gradient with neutral midpoint for data with a meaningful center
249- **Categorical data**: Use distinct hues, maximum 6-8 before it gets confusing
250- **Avoid red/green only**: 8% of men are red-green colorblind. Use blue/orange as primary pair

Color

  • Use color purposefully: Color should encode data, not decorate
  • Highlight the story: Use a bright accent color for the key insight; grey everything else
  • Sequential data: Use a single-hue gradient (light to dark) for ordered values
  • Diverging data: Use a two-hue gradient with neutral midpoint for data with a meaningful center
  • Categorical data: Use distinct hues, maximum 6-8 before it gets confusing
  • Avoid red/green only: 8% of men are red-green colorblind. Use blue/orange as primary pair
Raw lines 243 to 251
252### Typography
254- **Title states the insight**: "Revenue grew 23% YoY" beats "Revenue by Month"
255- **Subtitle adds context**: Date range, filters applied, data source
256- **Axis labels are readable**: Never rotated 90 degrees if avoidable. Shorten or wrap instead
257- **Data labels add precision**: Use on key points, not every single bar
258- **Annotation highlights**: Call out specific points with text annotations

Typography

  • Title states the insight: "Revenue grew 23% YoY" beats "Revenue by Month"
  • Subtitle adds context: Date range, filters applied, data source
  • Axis labels are readable: Never rotated 90 degrees if avoidable. Shorten or wrap instead
  • Data labels add precision: Use on key points, not every single bar
  • Annotation highlights: Call out specific points with text annotations
Raw lines 252 to 259
260### Layout
262- **Reduce chart junk**: Remove gridlines, borders, backgrounds that don't carry information
263- **Sort meaningfully**: Categories sorted by value (not alphabetically) unless there's a natural order (months, stages)
264- **Appropriate aspect ratio**: Time series wider than tall (3:1 to 2:1); comparisons can be squarer
265- **White space is good**: Don't cram charts together. Give each visualization room to breathe

Layout

  • Reduce chart junk: Remove gridlines, borders, backgrounds that don't carry information
  • Sort meaningfully: Categories sorted by value (not alphabetically) unless there's a natural order (months, stages)
  • Appropriate aspect ratio: Time series wider than tall (3:1 to 2:1); comparisons can be squarer
  • White space is good: Don't cram charts together. Give each visualization room to breathe
Raw lines 260 to 266
267### Accuracy
269- **Bar charts start at zero**: Always. A bar from 95 to 100 exaggerates a 5% difference
270- **Line charts can have non-zero baselines**: When the range of variation is meaningful
271- **Consistent scales across panels**: When comparing multiple charts, use the same axis range
272- **Show uncertainty**: Error bars, confidence intervals, or ranges when data is uncertain
273- **Label your axes**: Never make the reader guess what the numbers mean

Accuracy

  • Bar charts start at zero: Always. A bar from 95 to 100 exaggerates a 5% difference
  • Line charts can have non-zero baselines: When the range of variation is meaningful
  • Consistent scales across panels: When comparing multiple charts, use the same axis range
  • Show uncertainty: Error bars, confidence intervals, or ranges when data is uncertain
  • Label your axes: Never make the reader guess what the numbers mean
Raw lines 267 to 274
275## Accessibility Considerations

Accessibility Considerations

Raw lines 275 to 276
277### Color Blindness
279- Never rely on color alone to distinguish data series
280- Add pattern fills, different line styles (solid, dashed, dotted), or direct labels
281- Test with a colorblind simulator (e.g., Coblis, Sim Daltonism)
282- Use the colorblind-friendly palette: `sns.color_palette("colorblind")`

Color Blindness

  • Never rely on color alone to distinguish data series
  • Add pattern fills, different line styles (solid, dashed, dotted), or direct labels
  • Test with a colorblind simulator (e.g., Coblis, Sim Daltonism)
  • Use the colorblind-friendly palette: sns.color_palette("colorblind")
Raw lines 277 to 283
284### Screen Readers
286- Include alt text describing the chart's key finding
287- Provide a data table alternative alongside the visualization
288- Use semantic titles and labels

Screen Readers

  • Include alt text describing the chart's key finding
  • Provide a data table alternative alongside the visualization
  • Use semantic titles and labels
Raw lines 284 to 289
290### General Accessibility
292- Sufficient contrast between data elements and background
293- Text size minimum 10pt for labels, 12pt for titles
294- Avoid conveying information only through spatial position (add labels)
295- Consider printing: does the chart work in black and white?

General Accessibility

  • Sufficient contrast between data elements and background
  • Text size minimum 10pt for labels, 12pt for titles
  • Avoid conveying information only through spatial position (add labels)
  • Consider printing: does the chart work in black and white?
Raw lines 290 to 296
297### Accessibility Checklist
299Before sharing a visualization:
300- [ ] Chart works without color (patterns, labels, or line styles differentiate series)
301- [ ] Text is readable at standard zoom level
302- [ ] Title describes the insight, not just the data
303- [ ] Axes are labeled with units
304- [ ] Legend is clear and positioned without obscuring data
305- [ ] Data source and date range are noted

Accessibility Checklist

Before sharing a visualization:

  • [ ] Chart works without color (patterns, labels, or line styles differentiate series)
  • [ ] Text is readable at standard zoom level
  • [ ] Title describes the insight, not just the data
  • [ ] Axes are labeled with units
  • [ ] Legend is clear and positioned without obscuring data
  • [ ] Data source and date range are noted
Raw lines 297 to 305

From anthropics/knowledge-work-plugins at 2574e29, 2026-10-27. Skills read by DeepSeek V4.1 Flash on 2026-11-04. Summary and techniques by Claude Opus 5.5 on 2026-11-06.