All skills
Skillintermediate

Seaborn Function Reference

This document provides a comprehensive reference for all major seaborn functions, organized by category.

Claude Code Knowledge Pack7/10/2026

Overview

Seaborn Function Reference

This document provides a comprehensive reference for all major seaborn functions, organized by category.

Relational Plots

scatterplot()

Purpose: Create a scatter plot with points representing individual observations.

Key Parameters:

  • data - DataFrame, array, or dict of arrays
  • x, y - Variables for x and y axes
  • hue - Grouping variable for color encoding
  • size - Grouping variable for size encoding
  • style - Grouping variable for marker style
  • palette - Color palette name or list
  • hue_order - Order for categorical hue levels
  • hue_norm - Normalization for numeric hue (tuple or Normalize object)
  • sizes - Size range for size encoding (tuple or dict)
  • size_order - Order for categorical size levels
  • size_norm - Normalization for numeric size
  • markers - Marker style(s) (string, list, or dict)
  • style_order - Order for categorical style levels
  • legend - How to draw legend: "auto", "brief", "full", or False
  • ax - Matplotlib axes to plot on

Example:

sns.scatterplot(data=df, x='height', y='weight',
                hue='gender', size='age', style='smoker',
                palette='Set2', sizes=(20, 200))

lineplot()

Purpose: Draw a line plot with automatic aggregation and confidence intervals for repeated measures.

Key Parameters:

  • data - DataFrame, array, or dict of arrays
  • x, y - Variables for x and y axes
  • hue - Grouping variable for color encoding
  • size - Grouping variable for line width
  • style - Grouping variable for line style (dashes)
  • units - Grouping variable for sampling units (no aggregation within units)
  • estimator - Function for aggregating across observations (default: mean)
  • errorbar - Method for error bars: "sd", "se", "pi", ("ci", level), ("pi", level), or None
  • n_boot - Number of bootstrap iterations for CI computation
  • seed - Random seed for reproducible bootstrapping
  • sort - Sort data before plotting
  • err_style - "band" or "bars" for error representation
  • err_kws - Additional parameters for error representation
  • markers - Marker style(s) for emphasizing data points
  • dashes - Dash style(s) for lines
  • legend - How to draw legend
  • ax - Matplotlib axes to plot on

Example:

sns.lineplot(data=timeseries, x='time', y='signal',
             hue='condition', style='subject',
             errorbar=('ci', 95), markers=True)

relplot()

Purpose: Figure-level interface for drawing relational plots (scatter or line) onto a FacetGrid.

Key Parameters: All parameters from scatterplot() and lineplot(), plus:

  • kind - "scatter" or "line"
  • col - Categorical variable for column facets
  • row - Categorical variable for row facets
  • col_wrap - Wrap columns after this many columns
  • col_order - Order for column facet levels
  • row_order - Order for row facet levels
  • height - Height of each facet in inches
  • aspect - Aspect ratio (width = height * aspect)
  • facet_kws - Additional parameters for FacetGrid

Example:

sns.relplot(data=df, x='time', y='measurement',
            hue='treatment', style='batch',
            col='cell_line', row='timepoint',
            kind='line', height=3, aspect=1.5)

Distribution Plots

histplot()

Purpose: Plot univariate or bivariate histograms with flexible binning.

Key Parameters:

  • data - DataFrame, array, or dict
  • x, y - Variables (y optional for bivariate)
  • hue - Grouping variable
  • weights - Variable for weighting observations
  • stat - Aggregate statistic: "count", "frequency", "probability", "percent", "density"
  • bins - Number of bins, bin edges, or method ("auto", "fd", "doane", "scott", "stone", "rice", "sturges", "sqrt")
  • binwidth - Width of bins (overrides bins)
  • binrange - Range for binning (tuple)
  • discrete - Treat x as discrete (centers bars on values)
  • cumulative - Compute cumulative distribution
  • common_bins - Use same bins for all hue levels
  • common_norm - Normalize across hue levels
  • multiple - How to handle hue: "layer", "dodge", "stack", "fill"
  • element - Visual element: "bars", "step", "poly"
  • fill - Fill bars/elements
  • shrink - Scale bar width (for multiple="dodge")
  • kde - Overlay KDE estimate
  • kde_kws - Parameters for KDE
  • line_kws - Parameters for step/poly elements
  • thresh - Minimum count threshold for bins
  • pthresh - Minimum probability threshold
  • pmax - Maximum probability for color scaling
  • log_scale - Log scale for axis (bool or base)
  • legend - Whether to show legend
  • ax - Matplotlib axes

Example:

sns.histplot(data=df, x='measurement', hue='condition',
             stat='density', bins=30, kde=True,
             multiple='layer', alpha=0.5)

kdeplot()

Purpose: Plot univariate or bivariate kernel density estimates.

Key Parameters:

  • data - DataFrame, array, or dict
  • x, y - Variables (y optional for bivariate)
  • hue - Grouping variable
  • weights - Variable for weighting observations
  • palette - Color palette
  • hue_order - Order for hue levels
  • hue_norm - Normalization for numeric hue
  • multiple - How to handle hue: "layer", "stack", "fill"
  • common_norm - Normalize across hue levels
  • common_grid - Use same grid for all hue levels
  • cumulative - Compute cumulative distribution
  • bw_method - Method for bandwidth: "scott", "silverman", or scalar
  • bw_adjust - Bandwidth multiplier (higher = smoother)
  • log_scale - Log scale for axis
  • levels - Number or values for contour levels (bivariate)
  • thresh - Minimum density threshold for contours
  • gridsize - Grid resolution
  • cut - Extension beyond data extremes (in bandwidth units)
  • clip - Data range for curve (tuple)
  • fill - Fill area under curve/contours
  • legend - Whether to show legend
  • ax - Matplotlib axes

Example:

# Univariate
sns.kdeplot(data=df, x='measurement', hue='condition',
            fill=True, common_norm=False, bw_adjust=1.5)

# Bivariate
sns.kdeplot(data=df, x='var1', y='var2',
            fill=True, levels=10, thresh=0.05)

ecdfplot()

Purpose: Plot empirical cumulative distribution functions.

Key Parameters:

  • data - DataFrame, array, or dict
  • x, y - Variables (specify one)
  • hue - Grouping variable
  • weights - Variable for weighting observations
  • stat - "proportion" or "count"
  • complementary - Plot complementary CDF (1 - ECDF)
  • palette - Color palette
  • hue_order - Order for hue levels
  • hue_norm - Normalization for numeric hue
  • log_scale - Log scale for axis
  • legend - Whether to show legend
  • ax - Matplotlib axes

Example:

sns.ecdfplot(data=df, x='response_time', hue='treatment',
             stat='proportion', complementary=False)

rugplot()

Purpose: Plot tick marks showing individual observations along an axis.

Key Parameters:

  • data - DataFrame, array, or dict
  • x, y - Variable (specify one)
  • hue - Grouping variable
  • height - Height of ticks (proportion of axis)
  • expand_margins - Add margin space for rug
  • palette - Color palette
  • hue_order - Order for hue levels
  • hue_norm - Normalization for numeric hue
  • legend - Whether to show legend
  • ax - Matplotlib axes

Example:

sns.rugplot(data=df, x='value', hue='category', height=0.05)

displot()

Purpose: Figure-level interface for distribution plots onto a FacetGrid.

Key Parameters: All parameters from histplot(), kdeplot(), and ecdfplot(), plus:

  • kind - "hist", "kde", "ecdf"
  • rug - Add rug plot on marginal axes
  • rug_kws - Parameters for rug plot
  • col - Categorical variable for column facets
  • row - Categorical variable for row facets
  • col_wrap - Wrap columns
  • col_order - Order for column facets
  • row_order - Order for row facets
  • height - Height of each facet
  • aspect - Aspect ratio
  • facet_kws - Additional parameters for FacetGrid

Example:

sns.displot(data=df, x='measurement', hue='treatment',
            col='timepoint', kind='kde', fill=True,
            height=3, aspect=1.5, rug=True)

jointplot()

Purpose: Draw a bivariate plot with marginal univariate plots.

Key Parameters:

  • data - DataFrame
  • x, y - Variables for x and y axes
  • hue - Grouping variable
  • kind - "scatter", "kde", "hist", "hex", "reg", "resid"
  • height - Size of the figure (square)
  • ratio - Ratio of joint to marginal axes
  • space - Space between joint and marginal axes
  • dropna - Drop missing values
  • xlim, ylim - Axis limits (tuples)
  • marginal_ticks - Show ticks on marginal axes
  • joint_kws - Parameters for joint plot
  • marginal_kws - Parameters for marginal plots
  • hue_order - Order for hue levels
  • palette - Color palette

Example:

sns.jointplot(data=df, x='var1', y='var2', hue='group',
              kind='scatter', height=6, ratio=4,
              joint_kws={'alpha': 0.5})

pairplot()

Purpose: Plot pairwise relationships in a dataset.

Key Parameters:

  • data - DataFrame
  • hue - Grouping variable for color encoding
  • hue_order - Order for hue levels
  • palette - Color palette
  • vars - Variables to plot (default: all numeric)
  • x_vars, y_vars - Variables for x and y axes (non-square grid)
  • kind - "scatter", "kde", "hist", "reg"
  • diag_kind - "auto", "hist", "kde", None
  • markers - Marker style(s)
  • height - Height of each facet
  • aspect - Aspect ratio
  • corner - Plot only lower triangle
  • dropna - Drop missing values
  • plot_kws - Parameters for non-diagonal plots
  • diag_kws - Parameters for diagonal plots
  • grid_kws - Parameters for PairGrid

Example:

sns.pairplot(data=df, hue='species', palette='Set2',
             vars=['sepal_length', 'sepal_width', 'petal_length'],
             corner=True, height=2.5)

Categorical Plots

stripplot()

Purpose: Draw a categorical scatterplot with jittered points.

Key Parameters:

  • data - DataFrame, array, or dict
  • x, y - Variables (one categorical, one continuous)
  • hue - Grouping variable
  • order - Order for categorical levels
  • hue_order - Order for hue levels
  • jitter - Amount of jitter: True, float, or False
  • dodge - Separate hue levels side-by-side
  • orient - "v" or "h" (usually inferred)
  • color - Single color for all elements
  • palette - Color palette
  • size - Marker size
  • edgecolor - Marker edge color
  • linewidth - Marker edge width
  • native_scale - Use numeric scale for categorical axis
  • formatter - Formatter for categorical axis
  • legend - Whether to show legend
  • ax - Matplotlib axes

Example:

sns.stripplot(data=df, x='day', y='total_bill',
              hue='sex', dodge=True, jitter=0.2)

swarmplot()

Purpose: Draw a categorical scatterplot with non-overlapping points.

Key Parameters: Same as stripplot(), except:

  • No jitter parameter
  • size - Marker size (important for avoiding overlap)
  • warn_thresh - Threshold for warning about too many points (default: 0.05)

Note: Computationally intensive for large datasets. Use stripplot for >1000 points.

Example:

sns.swarmplot(data=df, x='day', y='total_bill',
              hue='time', dodge=True, size=5)

boxplot()

Purpose: Draw a box plot showing quartiles and outliers.

Key Parameters:

  • data - DataFrame, array, or dict
  • x, y - Variables (one categorical, one continuous)
  • hue - Grouping variable
  • order - Order for categorical levels
  • hue_order - Order for hue levels
  • orient - "v" or "h"
  • color - Single color for boxes
  • palette - Color palette
  • saturation - Color saturation intensity
  • width - Width of boxes
  • dodge - Separate hue levels side-by-side
  • fliersize - Size of outlier markers
  • linewidth - Box line width
  • whis - IQR multiplier for whiskers (default: 1.5)
  • notch - Draw notched boxes
  • showcaps - Show whisker caps
  • showmeans - Show mean value
  • meanprops - Properties for mean marker
  • boxprops - Properties for boxes
  • whiskerprops - Properties for whiskers
  • capprops - Properties for caps
  • flierprops - Properties for outliers
  • medianprops - Properties for median line
  • native_scale - Use numeric scale
  • formatter - Formatter for categorical axis
  • legend - Whether to show legend
  • ax - Matplotlib axes

Example:

sns.boxplot(data=df, x='day', y='total_bill',
            hue='smoker', palette='Set3',
            showmeans=True, notch=True)

violinplot()

Purpose: Draw a violin plot combining boxplot and KDE.

Key Parameters: Same as boxplot(), plus:

  • bw_method - KDE bandwidth method
  • bw_adjust - KDE bandwidth multiplier
  • cut - KDE extension beyond extremes
  • density_norm - "area", "count", "width"
  • inner - "box", "quartile", "point", "stick", None
  • split - Split violins for hue comparison
  • scale - Scaling method: "area", "count", "width"
  • scale_hue - Scale across hue levels
  • gridsize - KDE grid resolution

Example:

sns.violinplot(data=df, x='day', y='total_bill',
               hue='sex', split=True, inner='quartile',
               palette='muted')

boxenplot()

Purpose: Draw enhanced box plot for larger datasets showing more quantiles.

Key Parameters: Same as boxplot(), plus:

  • k_depth - "tukey", "proportion", "trustworthy", "full", or int
  • outlier_prop - Proportion of data as outliers
  • trust_alpha - Alpha for trustworthy depth
  • showfliers - Show outlier points

Example:

sns.boxenplot(data=df, x='day', y='total_bill',
              hue='time', palette='Set2')

barplot()

Purpose: Draw a bar plot with error bars showing statistical estimates.

Key Parameters:

  • data - DataFrame, array, or dict
  • x, y - Variables (one categorical, one continuous)
  • hue - Grouping variable
  • order - Order for categorical levels
  • hue_order - Order for hue levels
  • estimator - Aggregation function (default: mean)
  • errorbar - Error representation: "sd", "se", "pi", ("ci", level), ("pi", level), or None
  • n_boot - Bootstrap iterations
  • seed - Random seed
  • units - Identifier for sampling units
  • weights - Observation weights
  • orient - "v" or "h"
  • color - Single bar color
  • palette - Color palette
  • saturation - Color saturation
  • width - Bar width
  • dodge - Separate hue levels side-by-side
  • errcolor - Error bar color
  • errwidth - Error bar line width
  • capsize - Error bar cap width
  • native_scale - Use numeric scale
  • formatter - Formatter for categorical axis
  • legend - Whether to show legend
  • ax - Matplotlib axes

Example:

sns.barplot(data=df, x='day', y='total_bill',
            hue='sex', estimator='median',
            errorbar=('ci', 95), capsize=0.1)

countplot()

**Purpos