home / skills / eyadsibai / ltk / visualization

This skill helps you quickly create clear, publication-quality visualizations in Python by guiding library choices and best practices across common chart types.

npx playbooks add skill eyadsibai/ltk --skill visualization

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
2.9 KB
---
name: visualization
description: Use when "data visualization", "plotting", "charts", "matplotlib", "plotly", "seaborn", "graphs", "figures", "heatmap", "scatter plot", "bar chart", "interactive plots"
version: 1.0.0
---

# Data Visualization

Python libraries for creating static and interactive visualizations.

## Comparison

| Library | Best For | Interactive | Learning Curve |
|---------|----------|-------------|----------------|
| **Matplotlib** | Publication, full control | No | Steep |
| **Seaborn** | Statistical, beautiful defaults | No | Easy |
| **Plotly** | Dashboards, web | Yes | Medium |
| **Altair** | Declarative, grammar of graphics | Yes | Easy |

---

## Matplotlib

Foundation library - everything else builds on it.

**Strengths**: Complete control, publication quality, extensive customization
**Limitations**: Verbose, dated API, learning curve

**Key concepts:**

- **Figure**: The entire canvas
- **Axes**: Individual plot area (a figure can have multiple)
- **Object-oriented API**: `fig, ax = plt.subplots()` - preferred over pyplot

---

## Seaborn

Statistical visualization with beautiful defaults.

**Strengths**: One-liners for complex plots, automatic aesthetics, works with pandas
**Limitations**: Less control than matplotlib, limited customization

**Key concepts:**

- **Statistical plots**: histplot, boxplot, violinplot, regplot
- **Categorical plots**: boxplot, stripplot, swarmplot
- **Matrix plots**: heatmap, clustermap
- Built on matplotlib - use matplotlib for fine-tuning

---

## Plotly

Interactive, web-ready visualizations.

**Strengths**: Interactivity (zoom, pan, hover), web embedding, Dash integration
**Limitations**: Large bundle size, different mental model

**Key concepts:**

- **Express API**: High-level, similar to seaborn (`px.scatter()`)
- **Graph Objects**: Low-level, full control (`go.Figure()`)
- Output as HTML or embedded in web apps

---

## Chart Type Selection

| Data Type | Chart |
|-----------|-------|
| Trends over time | Line chart |
| Distribution | Histogram, box plot, violin |
| Comparison | Bar chart, grouped bar |
| Relationship | Scatter, bubble |
| Composition | Pie, stacked bar |
| Correlation | Heatmap |
| Part-to-whole | Treemap, sunburst |

---

## Design Principles

- **Data-ink ratio**: Maximize data, minimize decoration
- **Color**: Use sparingly, consider colorblind users
- **Labels**: Always label axes, include units
- **Legend**: Only when necessary, prefer direct labeling
- **Aspect ratio**: ~1.6:1 (golden ratio) for most plots

---

## Decision Guide

| Task | Recommendation |
|------|----------------|
| Publication figures | Matplotlib |
| Quick EDA | Seaborn |
| Statistical analysis | Seaborn |
| Interactive dashboards | Plotly |
| Web embedding | Plotly |
| Complex customization | Matplotlib |

## Resources

- Matplotlib: <https://matplotlib.org/stable/gallery/>
- Seaborn: <https://seaborn.pydata.org/examples/>
- Plotly: <https://plotly.com/python/>

Overview

This skill provides practical guidance for creating static and interactive data visualizations in Python using libraries like Matplotlib, Seaborn, Plotly, and Altair. It helps you choose the right chart type, apply design principles, and understand when to use each library to produce publication-quality figures or interactive dashboards. The content focuses on actionable recommendations and common workflows for exploratory data analysis and presentation-ready plots.

How this skill works

The skill summarizes strengths, limitations, and key concepts for each major library so you can pick the appropriate tool quickly. It describes core chart types mapped to data problems (distribution, trend, relationship, composition) and gives concise design rules to improve clarity and accessibility. Practical tips include when to use high-level APIs versus low-level control and how to combine libraries (e.g., Seaborn for quick EDA, Matplotlib for fine-tuning, Plotly for interactivity).

When to use it

  • When you need publication-quality, fully customized figures: use Matplotlib.
  • For fast statistical plots and attractive defaults during EDA: use Seaborn.
  • To build interactive, web-ready charts or dashboards: use Plotly (or Altair for declarative interactivity).
  • When mapping chart types to data tasks (trend, distribution, comparison, correlation).
  • When you need lightweight, declarative grammar of graphics: consider Altair.

Best practices

  • Choose the chart type that matches the analytical goal (e.g., line for trends, histogram for distribution).
  • Maximize data-ink ratio: remove unnecessary gridlines and decorations that do not add information.
  • Use color purposefully and test for colorblind accessibility; prefer palettes with perceptual ordering for sequential data.
  • Always label axes and include units; prefer direct labeling over legends when possible.
  • Start with high-level APIs (Seaborn/Plotly Express) for speed, then move to Matplotlib or Plotly graph objects for fine-tuning.

Example use cases

  • Exploratory analysis of a dataset: quick histograms, boxplots, and pairwise scatter matrices with Seaborn.
  • Preparing figures for a paper: build exact layouts, annotate subplots, and export vector graphics with Matplotlib.
  • Interactive dashboards: create responsive scatter and line charts with Plotly and embed them in a web app or export HTML.
  • Correlation analysis: generate heatmaps or clustermaps to visualize feature relationships.
  • Comparing groups: grouped bar charts or violin plots to show distributional differences across categories.

FAQ

Which library should I learn first?

Start with Seaborn for fast, attractive statistical plots that work well with pandas; learn Matplotlib next to gain fine-grained control.

When should I use Plotly instead of Matplotlib?

Use Plotly when you need interactivity (hover, zoom, web embedding) or when building dashboards; use Matplotlib for static, publication-ready figures.