$npx -y skills add anthropics/knowledge-work-plugins --skill data-visualizationdata-visualization is an agent skill published from anthropics/knowledge-work-plugins, installable through the skills CLI.
| 1 | # Data Visualization Skill |
| 2 | |
| 3 | Chart selection guidance, Python visualization code patterns, design principles, and accessibility considerations for creating effective data visualizations. |
| 4 | |
| 5 | ## Chart Selection Guide |
| 6 | |
| 7 | ### Choose by Data Relationship |
| 8 | |
| 9 | | What You're Showing | Best Chart | Alternatives | |
| 10 | |---|---|---| |
| 11 | | **Trend over time** | Line chart | Area chart (if showing cumulative or composition) | |
| 12 | | **Comparison across categories** | Vertical bar chart | Horizontal bar (many categories), lollipop chart | |
| 13 | | **Ranking** | Horizontal bar chart | Dot plot, slope chart (comparing two periods) | |
| 14 | | **Part-to-whole composition** | Stacked bar chart | Treemap (hierarchical), waffle chart | |
| 15 | | **Composition over time** | Stacked area chart | 100% stacked bar (for proportion focus) | |
| 16 | | **Distribution** | Histogram | Box plot (comparing groups), violin plot, strip plot | |
| 17 | | **Correlation (2 variables)** | Scatter plot | Bubble chart (add 3rd variable as size) | |
| 18 | | **Correlation (many variables)** | Heatmap (correlation matrix) | Pair plot | |
| 19 | | **Geographic patterns** | Choropleth map | Bubble map, hex map | |
| 20 | | **Flow / process** | Sankey diagram | Funnel chart (sequential stages) | |
| 21 | | **Relationship network** | Network graph | Chord diagram | |
| 22 | | **Performance vs. target** | Bullet chart | Gauge (single KPI only) | |
| 23 | | **Multiple KPIs at once** | Small multiples | Dashboard with separate charts | |
| 24 | |
| 25 | ### When NOT to Use Certain Charts |
| 26 | |
| 27 | - **Pie charts**: Avoid unless <6 categories and exact proportions matter less than rough comparison. Humans are bad at comparing angles. Use bar charts instead. |
| 28 | - **3D charts**: Never. They distort perception and add no information. |
| 29 | - **Dual-axis charts**: Use cautiously. They can mislead by implying correlation. Clearly label both axes if used. |
| 30 | - **Stacked bar (many categories)**: Hard to compare middle segments. Use small multiples or grouped bars instead. |
| 31 | - **Donut charts**: Slightly better than pie charts but same fundamental issues. Use for single KPI display at most. |
| 32 | |
| 33 | ## Python Visualization Code Patterns |
| 34 | |
| 35 | ### Setup and Style |
| 36 | |
| 37 | ```python |
| 38 | import matplotlib.pyplot as plt |
| 39 | import matplotlib.ticker as mticker |
| 40 | import seaborn as sns |
| 41 | import pandas as pd |
| 42 | import numpy as np |
| 43 | |
| 44 | # Professional style setup |
| 45 | plt.style.use('seaborn-v0_8-whitegrid') |
| 46 | plt.rcParams.update({ |
| 47 | 'figure.figsize': (10, 6), |
| 48 | 'figure.dpi': 150, |
| 49 | 'font.size': 11, |
| 50 | 'axes.titlesize': 14, |
| 51 | 'axes.titleweight': 'bold', |
| 52 | 'axes.labelsize': 11, |
| 53 | 'xtick.labelsize': 10, |
| 54 | 'ytick.labelsize': 10, |
| 55 | 'legend.fontsize': 10, |
| 56 | 'figure.titlesize': 16, |
| 57 | }) |
| 58 | |
| 59 | # Colorblind-friendly palettes |
| 60 | PALETTE_CATEGORICAL = ['#4C72B0', '#DD8452', '#55A868', '#C44E52', '#8172B3', '#937860'] |
| 61 | PALETTE_SEQUENTIAL = 'YlOrRd' |
| 62 | PALETTE_DIVERGING = 'RdBu_r' |
| 63 | ``` |
| 64 | |
| 65 | ### Line Chart (Time Series) |
| 66 | |
| 67 | ```python |
| 68 | fig, ax = plt.subplots(figsize=(10, 6)) |
| 69 | |
| 70 | for label, group in df.groupby('category'): |
| 71 | ax.plot(group['date'], group['value'], label=label, linewidth=2) |
| 72 | |
| 73 | ax.set_title('Metric Trend by Category', fontweight='bold') |
| 74 | ax.set_xlabel('Date') |
| 75 | ax.set_ylabel('Value') |
| 76 | ax.legend(loc='upper left', frameon=True) |
| 77 | ax.spines['top'].set_visible(False) |
| 78 | ax.spines['right'].set_visible(False) |
| 79 | |
| 80 | # Format dates on x-axis |
| 81 | fig.autofmt_xdate() |
| 82 | |
| 83 | plt.tight_layout() |
| 84 | plt.savefig('trend_chart.png', dpi=150, bbox_inches='tight') |
| 85 | ``` |
| 86 | |
| 87 | ### Bar Chart (Comparison) |
| 88 | |
| 89 | ```python |
| 90 | fig, ax = plt.subplots(figsize=(10, 6)) |
| 91 | |
| 92 | # Sort by value for easy reading |
| 93 | df_sorted = df.sort_values('metric', ascending=True) |
| 94 | |
| 95 | bars = ax.barh(df_sorted['category'], df_sorted['metric'], color=PALETTE_CATEGORICAL[0]) |
| 96 | |
| 97 | # Add value labels |
| 98 | for bar in bars: |
| 99 | width = bar.get_width() |
| 100 | ax.text(width + 0.5, bar.get_y() + bar.get_height()/2, |
| 101 | f'{width:,.0f}', ha='left', va='center', fontsize=10) |
| 102 | |
| 103 | ax.set_title('Metric by Category (Ranked)', fontweight='bold') |
| 104 | ax.set_xlabel('Metric Value') |
| 105 | ax.spines['top'].set_visible(False) |
| 106 | ax.spines['right'].set_visible(False) |
| 107 | |
| 108 | plt.tight_layout() |
| 109 | plt.savefig('bar_chart.png', dpi=150, bbox_inches='tight') |
| 110 | ``` |
| 111 | |
| 112 | ### Histogram (Distribution) |
| 113 | |
| 114 | ```python |
| 115 | fig, ax = plt.subplots(figsize=(10, 6)) |
| 116 | |
| 117 | ax.hist(df['value'], bins=30, color=PALETTE_CATEGORICAL[0], edgecolor='white', alpha=0.8) |
| 118 | |
| 119 | # Add mean and median lines |
| 120 | mean_val = df['value'].mean() |
| 121 | median_val = df['value'].median() |
| 122 | ax.axvline(mean_val, color='red', linestyle='--', linewidth=1.5, label=f'Mean: {mean_val:,.1f}') |
| 123 | ax.axvline(median_val, color='green', linestyle='--', linewidth=1.5, label=f'Median: {median_val:,.1f}') |
| 124 | |
| 125 | ax.set_title('Distribution of Values', fontweight='bold') |
| 126 | ax.set_xlabel('Value') |
| 127 | ax.set_ylabel('Frequency') |
| 128 | ax.legend() |
| 129 | ax.spines['top'].set_visible(False) |
| 130 | ax.spines['right'].set_visible(False) |
| 131 | |
| 132 | plt.ti |