$npx -y skills add ai4protein/VenusFactory2 --skill seabornStatistical visualization with pandas integration. Use for quick exploration of distributions, relationships, and categorical comparisons with attractive defaults. Best for box plots, violin plots, pair plots, heatmaps. Built on matplotlib. For interactive plots use plotly; for p
| 1 | # Seaborn Statistical Visualization |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Seaborn is a Python visualization library for creating publication-quality statistical graphics. Use this skill for dataset-oriented plotting, multivariate analysis, automatic statistical estimation, and complex multi-panel figures with minimal code. |
| 6 | |
| 7 | ## Design Philosophy |
| 8 | |
| 9 | Seaborn follows these core principles: |
| 10 | |
| 11 | 1. **Dataset-oriented**: Work directly with DataFrames and named variables rather than abstract coordinates |
| 12 | 2. **Semantic mapping**: Automatically translate data values into visual properties (colors, sizes, styles) |
| 13 | 3. **Statistical awareness**: Built-in aggregation, error estimation, and confidence intervals |
| 14 | 4. **Aesthetic defaults**: Publication-ready themes and color palettes out of the box |
| 15 | 5. **Matplotlib integration**: Full compatibility with matplotlib customization when needed |
| 16 | |
| 17 | ## Quick Start |
| 18 | |
| 19 | ```python |
| 20 | import seaborn as sns |
| 21 | import matplotlib.pyplot as plt |
| 22 | import pandas as pd |
| 23 | |
| 24 | # Load example dataset |
| 25 | df = sns.load_dataset('tips') |
| 26 | |
| 27 | # Create a simple visualization |
| 28 | sns.scatterplot(data=df, x='total_bill', y='tip', hue='day') |
| 29 | plt.show() |
| 30 | ``` |
| 31 | |
| 32 | ## Core Plotting Interfaces |
| 33 | |
| 34 | ### Function Interface (Traditional) |
| 35 | |
| 36 | The function interface provides specialized plotting functions organized by visualization type. Each category has **axes-level** functions (plot to single axes) and **figure-level** functions (manage entire figure with faceting). |
| 37 | |
| 38 | **When to use:** |
| 39 | - Quick exploratory analysis |
| 40 | - Single-purpose visualizations |
| 41 | - When you need a specific plot type |
| 42 | |
| 43 | ### Objects Interface (Modern) |
| 44 | |
| 45 | The `seaborn.objects` interface provides a declarative, composable API similar to ggplot2. Build visualizations by chaining methods to specify data mappings, marks, transformations, and scales. |
| 46 | |
| 47 | **When to use:** |
| 48 | - Complex layered visualizations |
| 49 | - When you need fine-grained control over transformations |
| 50 | - Building custom plot types |
| 51 | - Programmatic plot generation |
| 52 | |
| 53 | ```python |
| 54 | from seaborn import objects as so |
| 55 | |
| 56 | # Declarative syntax |
| 57 | ( |
| 58 | so.Plot(data=df, x='total_bill', y='tip') |
| 59 | .add(so.Dot(), color='day') |
| 60 | .add(so.Line(), so.PolyFit()) |
| 61 | ) |
| 62 | ``` |
| 63 | |
| 64 | ## Plotting Functions by Category |
| 65 | |
| 66 | ### Relational Plots (Relationships Between Variables) |
| 67 | |
| 68 | **Use for:** Exploring how two or more variables relate to each other |
| 69 | |
| 70 | - `scatterplot()` - Display individual observations as points |
| 71 | - `lineplot()` - Show trends and changes (automatically aggregates and computes CI) |
| 72 | - `relplot()` - Figure-level interface with automatic faceting |
| 73 | |
| 74 | **Key parameters:** |
| 75 | - `x`, `y` - Primary variables |
| 76 | - `hue` - Color encoding for additional categorical/continuous variable |
| 77 | - `size` - Point/line size encoding |
| 78 | - `style` - Marker/line style encoding |
| 79 | - `col`, `row` - Facet into multiple subplots (figure-level only) |
| 80 | |
| 81 | ```python |
| 82 | # Scatter with multiple semantic mappings |
| 83 | sns.scatterplot(data=df, x='total_bill', y='tip', |
| 84 | hue='time', size='size', style='sex') |
| 85 | |
| 86 | # Line plot with confidence intervals |
| 87 | sns.lineplot(data=timeseries, x='date', y='value', hue='category') |
| 88 | |
| 89 | # Faceted relational plot |
| 90 | sns.relplot(data=df, x='total_bill', y='tip', |
| 91 | col='time', row='sex', hue='smoker', kind='scatter') |
| 92 | ``` |
| 93 | |
| 94 | ### Distribution Plots (Single and Bivariate Distributions) |
| 95 | |
| 96 | **Use for:** Understanding data spread, shape, and probability density |
| 97 | |
| 98 | - `histplot()` - Bar-based frequency distributions with flexible binning |
| 99 | - `kdeplot()` - Smooth density estimates using Gaussian kernels |
| 100 | - `ecdfplot()` - Empirical cumulative distribution (no parameters to tune) |
| 101 | - `rugplot()` - Individual observation tick marks |
| 102 | - `displot()` - Figure-level interface for univariate and bivariate distributions |
| 103 | - `jointplot()` - Bivariate plot with marginal distributions |
| 104 | - `pairplot()` - Matrix of pairwise relationships across dataset |
| 105 | |
| 106 | **Key parameters:** |
| 107 | - `x`, `y` - Variables (y optional for univariate) |
| 108 | - `hue` - Separate distributions by category |
| 109 | - `stat` - Normalization: "count", "frequency", "probability", "density" |
| 110 | - `bins` / `binwidth` - Histogram binning control |
| 111 | - `bw_adjust` - KDE bandwidth multiplier (higher = smoother) |
| 112 | - `fill` - Fill area under curve |
| 113 | - `multiple` - How to handle hue: "layer", "stack", "dodge", "fill" |
| 114 | |
| 115 | ```python |
| 116 | # Histogram with density normalization |
| 117 | sns.histplot(data=df, x='total_bill', hue='time', |
| 118 | stat='density', multiple='stack') |
| 119 | |
| 120 | # Bivariate KDE with contours |
| 121 | sns.kdeplot(data=df, x='total_bill', y='tip', |
| 122 | fill=True, levels=5, thresh=0.1) |
| 123 | |
| 124 | # Joint plot with marginals |
| 125 | sns.jointplot(data=df, x='total_bill', y='tip', |
| 126 | kind='scatter', hue='time') |
| 127 | |
| 128 | # Pairwise |