Skill Tracer
Skills › Scientific Agent Skills › seaborn › function_reference.md

function_reference.md

783 lines · skills/seaborn/references/function_reference.md at 5f2bc03

Open on GitHub
1# Seaborn Function Reference
2
3This document provides a selected reference for major seaborn functions, organized by category. Reviewed against the [0.13.2 API](https://seaborn.pydata.org/api.html) and released signatures on 2026-10-01. Parameter lists below are selected, not complete signatures. Figure-level wrappers accept only parameters supported by their selected `kind`; they do not accept `ax`. Examples use illustrative input DataFrames.
4

Seaborn Function Reference

This document provides a selected reference for major seaborn functions, organized by category. Reviewed against the 0.13.2 API and released signatures on 2026-10-01. Parameter lists below are selected, not complete signatures. Figure-level wrappers accept only parameters supported by their selected kind; they do not accept ax. Examples use illustrative input DataFrames.

Raw lines 1 to 4
5## Relational Plots
6

Relational Plots

Raw lines 5 to 6
7### scatterplot()
8
9**Purpose:** Create a scatter plot with points representing individual observations.
11**Key Parameters:**
12- `data` - DataFrame, array, or dict of arrays
13- `x, y` - Variables for x and y axes
14- `hue` - Grouping variable for color encoding
15- `size` - Grouping variable for size encoding
16- `style` - Grouping variable for marker style
17- `palette` - Color palette name or list
18- `hue_order` - Order for categorical hue levels
19- `hue_norm` - Normalization for numeric hue (tuple or Normalize object)
20- `sizes` - Size range for size encoding (tuple or dict)
21- `size_order` - Order for categorical size levels
22- `size_norm` - Normalization for numeric size
23- `markers` - Marker style(s) (string, list, or dict)
24- `style_order` - Order for categorical style levels
25- `legend` - How to draw legend: "auto", "brief", "full", or False
26- `ax` - Matplotlib axes to plot on
28**Example:**
29```python
30sns.scatterplot(data=df, x='height', y='weight',
31 hue='gender', size='age', style='smoker',
32 palette='Set2', sizes=(20, 200))
33```

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))
Raw lines 7 to 34
35### lineplot()
37**Purpose:** Draw a line plot with aggregation and confidence intervals across observations at each x; repeated measures need an explicit sampling-unit strategy.
39**Key Parameters:**
40- `data` - DataFrame, array, or dict of arrays
41- `x, y` - Variables for x and y axes
42- `hue` - Grouping variable for color encoding
43- `size` - Grouping variable for line width
44- `style` - Grouping variable for line style (dashes)
45- `units` - Separate trajectory for each sampling unit; also set `estimator=None` (no aggregation)
46- `weights` - Observation weights; only mean estimation with CI or no error bars
47- `estimator` - Function for aggregating across observations (default: mean)
48- `errorbar` - Method for error bars: "sd", "se", "pi", ("ci", level), ("pi", level), or None
49- `n_boot` - Number of bootstrap iterations for CI computation
50- `seed` - Random seed for reproducible bootstrapping
51- `sort` - Sort data before plotting
52- `err_style` - "band" or "bars" for error representation
53- `err_kws` - Additional parameters for error representation
54- `markers` - Marker style(s) for emphasizing data points
55- `dashes` - Dash style(s) for lines
56- `legend` - How to draw legend
57- `ax` - Matplotlib axes to plot on
59**Example:**
60```python
61sns.lineplot(data=timeseries, x='time', y='signal',
62 hue='condition', units='subject',
63 estimator=None, errorbar=None, marker='o')
64```

lineplot()

Purpose: Draw a line plot with aggregation and confidence intervals across observations at each x; repeated measures need an explicit sampling-unit strategy.

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 - Separate trajectory for each sampling unit; also set estimator=None (no aggregation)
  • weights - Observation weights; only mean estimation with CI or no error bars
  • 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', units='subject',
             estimator=None, errorbar=None, marker='o')
Raw lines 35 to 65
66### relplot()
68**Purpose:** Figure-level interface for drawing relational plots (scatter or line) onto a FacetGrid.
70**Key Parameters:**
71Parameters for the selected `kind` (`scatterplot` or `lineplot`), except `ax`, plus:
72- `kind` - "scatter" or "line"
73- `col` - Categorical variable for column facets
74- `row` - Categorical variable for row facets
75- `col_wrap` - Wrap columns after this many columns
76- `col_order` - Order for column facet levels
77- `row_order` - Order for row facet levels
78- `height` - Height of each facet in inches
79- `aspect` - Aspect ratio (width = height * aspect)
80- `facet_kws` - Additional parameters for FacetGrid
82**Example:**
83```python
84sns.relplot(data=df, x='time', y='measurement',
85 hue='treatment', style='batch',
86 col='cell_line', row='timepoint',
87 kind='line', height=3, aspect=1.5)
88```

relplot()

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

Key Parameters: Parameters for the selected kind (scatterplot or lineplot), except ax, 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)
Raw lines 66 to 89
90## Distribution Plots

Distribution Plots

Raw lines 90 to 91
92### histplot()
94**Purpose:** Plot univariate or bivariate histograms with flexible binning.
96**Key Parameters:**
97- `data` - DataFrame, array, or dict
98- `x, y` - Variables (y optional for bivariate)
99- `hue` - Grouping variable
100- `weights` - Variable for weighting observations
101- `stat` - Aggregate statistic: "count", "frequency", "probability", "percent", "density"
102- `bins` - Number of bins, bin edges, or method ("auto", "fd", "doane", "scott", "stone", "rice", "sturges", "sqrt")
103- `binwidth` - Width of bins (overrides bins)
104- `binrange` - Range for binning (tuple)
105- `discrete` - Treat x as discrete (centers bars on values)
106- `cumulative` - Compute cumulative distribution
107- `common_bins` - Use same bins for all hue levels
108- `common_norm` - Normalize across hue levels
109- `multiple` - How to handle hue: "layer", "dodge", "stack", "fill"
110- `element` - Visual element: "bars", "step", "poly"
111- `fill` - Fill bars/elements
112- `shrink` - Scale bar width (for multiple="dodge")
113- `kde` - Overlay KDE estimate
114- `kde_kws` - Parameters for KDE
115- `line_kws` - Parameters for the KDE line when `kde=True`
116- `thresh` - Minimum count threshold for bins
117- `pthresh` - Minimum probability threshold
118- `pmax` - Maximum probability for color scaling
119- `log_scale` - Log scale for axis (bool or base)
120- `legend` - Whether to show legend
121- `ax` - Matplotlib axes
123**Example:**
124```python
125sns.histplot(data=df, x='measurement', hue='condition',
126 stat='density', bins=30, kde=True,
127 multiple='layer', alpha=0.5)
128```

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 the KDE line when kde=True
  • 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)
Raw lines 92 to 129
130### kdeplot()
132**Purpose:** Plot univariate or bivariate kernel density estimates.
134**Key Parameters:**
135- `data` - DataFrame, array, or dict
136- `x, y` - Variables (y optional for bivariate)
137- `hue` - Grouping variable
138- `weights` - Variable for weighting observations
139- `palette` - Color palette
140- `hue_order` - Order for hue levels
141- `hue_norm` - Normalization for numeric hue
142- `multiple` - How to handle hue: "layer", "stack", "fill"
143- `common_norm` - Normalize across hue levels
144- `common_grid` - Use same grid for all hue levels
145- `cumulative` - Compute cumulative distribution
146- `bw_method` - Method for bandwidth: "scott", "silverman", or scalar
147- `bw_adjust` - Bandwidth multiplier (higher = smoother)
148- `log_scale` - Log scale for axis
149- `levels` - Number or increasing iso-proportion levels in [0, 1] (bivariate)
150- `thresh` - Lowest iso-proportion contour level, not a raw density or p-value
151- `gridsize` - Grid resolution
152- `cut` - Extension beyond data extremes (in bandwidth units)
153- `clip` - Data range for curve (tuple)
154- `fill` - Fill area under curve/contours
155- `legend` - Whether to show legend
156- `ax` - Matplotlib axes
158**Example:**
159```python
160# Univariate
161sns.kdeplot(data=df, x='measurement', hue='condition',
162 fill=True, common_norm=False, bw_adjust=1.5)
164# Bivariate
165sns.kdeplot(data=df, x='var1', y='var2',
166 fill=True, levels=10, thresh=0.05)
167```

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 increasing iso-proportion levels in [0, 1] (bivariate)
  • thresh - Lowest iso-proportion contour level, not a raw density or p-value
  • 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)
Raw lines 130 to 168
169### ecdfplot()
171**Purpose:** Plot empirical cumulative distribution functions.
173**Key Parameters:**
174- `data` - DataFrame, array, or dict
175- `x, y` - Variables (specify one)
176- `hue` - Grouping variable
177- `weights` - Variable for weighting observations
178- `stat` - "proportion", "percent", or "count"
179- `complementary` - Plot complementary CDF (1 - ECDF)
180- `palette` - Color palette
181- `hue_order` - Order for hue levels
182- `hue_norm` - Normalization for numeric hue
183- `log_scale` - Log scale for axis
184- `legend` - Whether to show legend
185- `ax` - Matplotlib axes
187**Example:**
188```python
189sns.ecdfplot(data=df, x='response_time', hue='treatment',
190 stat='proportion', complementary=False)
191```

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", "percent", 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)
Raw lines 169 to 192
193### rugplot()
195**Purpose:** Plot tick marks showing individual observations along an axis.
197**Key Parameters:**
198- `data` - DataFrame, array, or dict
199- `x, y` - Variable (specify one)
200- `hue` - Grouping variable
201- `height` - Height of ticks (proportion of axis)
202- `expand_margins` - Add margin space for rug
203- `palette` - Color palette
204- `hue_order` - Order for hue levels
205- `hue_norm` - Normalization for numeric hue
206- `legend` - Whether to show legend
207- `ax` - Matplotlib axes
209**Example:**
210```python
211sns.rugplot(data=df, x='value', hue='category', height=0.05)
212```

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)
Raw lines 193 to 213
214### displot()
216**Purpose:** Figure-level interface for distribution plots onto a FacetGrid.
218**Key Parameters:**
219Parameters for the selected `kind` (`histplot`, `kdeplot`, or `ecdfplot`), except `ax`, plus:
220- `kind` - "hist", "kde", "ecdf"
221- `rug` - Add rug plot on marginal axes
222- `rug_kws` - Parameters for rug plot
223- `col` - Categorical variable for column facets
224- `row` - Categorical variable for row facets
225- `col_wrap` - Wrap columns
226- `col_order` - Order for column facets
227- `row_order` - Order for row facets
228- `height` - Height of each facet
229- `aspect` - Aspect ratio
230- `facet_kws` - Additional parameters for FacetGrid
232**Example:**
233```python
234sns.displot(data=df, x='measurement', hue='treatment',
235 col='timepoint', kind='kde', fill=True,
236 height=3, aspect=1.5, rug=True)
237```

displot()

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

Key Parameters: Parameters for the selected kind (histplot, kdeplot, or ecdfplot), except ax, 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)
Raw lines 214 to 238
239### jointplot()
241**Purpose:** Draw a bivariate plot with marginal univariate plots.
243**Key Parameters:**
244- `data` - DataFrame
245- `x, y` - Variables for x and y axes
246- `hue` - Grouping variable
247- `kind` - "scatter", "kde", "hist", "hex", "reg", "resid"
248- `height` - Size of the figure (square)
249- `ratio` - Ratio of joint to marginal axes
250- `space` - Space between joint and marginal axes
251- `dropna` - Drop missing values
252- `xlim, ylim` - Axis limits (tuples)
253- `marginal_ticks` - Show ticks on marginal axes
254- `joint_kws` - Parameters for joint plot
255- `marginal_kws` - Parameters for marginal plots
256- `hue_order` - Order for hue levels
257- `palette` - Color palette
259**Example:**
260```python
261sns.jointplot(data=df, x='var1', y='var2', hue='group',
262 kind='scatter', height=6, ratio=4,
263 joint_kws={'alpha': 0.5})
264```

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})
Raw lines 239 to 265
266### pairplot()
268**Purpose:** Plot pairwise relationships in a dataset.
270**Key Parameters:**
271- `data` - DataFrame
272- `hue` - Grouping variable for color encoding
273- `hue_order` - Order for hue levels
274- `palette` - Color palette
275- `vars` - Variables to plot (default: all numeric)
276- `x_vars, y_vars` - Variables for x and y axes (non-square grid)
277- `kind` - "scatter", "kde", "hist", "reg"
278- `diag_kind` - "auto", "hist", "kde", None
279- `markers` - Marker style(s)
280- `height` - Height of each facet
281- `aspect` - Aspect ratio
282- `corner` - Plot only lower triangle
283- `dropna` - Drop missing values
284- `plot_kws` - Parameters for non-diagonal plots
285- `diag_kws` - Parameters for diagonal plots
286- `grid_kws` - Parameters for PairGrid
288**Example:**
289```python
290sns.pairplot(data=df, hue='species', palette='Set2',
291 vars=['sepal_length', 'sepal_width', 'petal_length'],
292 corner=True, height=2.5)
293```

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)
Raw lines 266 to 294
295## Categorical Plots

Categorical Plots

Raw lines 295 to 296
297### stripplot()
299**Purpose:** Draw a categorical scatterplot with jittered points.
301**Key Parameters:**
302- `data` - DataFrame, array, or dict
303- `x, y` - Variables (one categorical, one continuous)
304- `hue` - Grouping variable
305- `order` - Order for categorical levels
306- `hue_order` - Order for hue levels
307- `jitter` - Amount of jitter: True, float, or False
308- `dodge` - Separate hue levels side-by-side
309- `orient` - "v" or "h" (usually inferred)
310- `color` - Single color for all elements
311- `palette` - Color palette
312- `size` - Marker size
313- `edgecolor` - Marker edge color
314- `linewidth` - Marker edge width
315- `native_scale` - Use numeric scale for categorical axis
316- `formatter` - Formats categorical values, affecting both grouping and tick labels
317- `legend` - Whether to show legend
318- `ax` - Matplotlib axes
320**Example:**
321```python
322sns.stripplot(data=df, x='day', y='total_bill',
323 hue='sex', dodge=True, jitter=0.2)
324```

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 - Formats categorical values, affecting both grouping and tick labels
  • 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)
Raw lines 297 to 325
326### swarmplot()
328**Purpose:** Draw a categorical scatterplot with non-overlapping points.
330**Key Parameters:**
331Same as `stripplot()`, except:
332- No `jitter` parameter
333- `size` - Marker size (important for avoiding overlap)
334- `warn_thresh` - Threshold for warning about too many points (default: 0.05)
336**Note:** Dense swarms can fail to place points without overlap; the practical limit depends on axes size, marker size, and group density. Check warnings and reduce marker size or use stripplot when needed.
338**Example:**
339```python
340sns.swarmplot(data=df, x='day', y='total_bill',
341 hue='time', dodge=True, size=5)
342```

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: Dense swarms can fail to place points without overlap; the practical limit depends on axes size, marker size, and group density. Check warnings and reduce marker size or use stripplot when needed.

Example:

sns.swarmplot(data=df, x='day', y='total_bill',
              hue='time', dodge=True, size=5)
Raw lines 326 to 343
344### boxplot()
346**Purpose:** Draw a box plot showing quartiles and outliers.
348**Key Parameters:**
349- `data` - DataFrame, array, or dict
350- `x, y` - Variables (one categorical, one continuous)
351- `hue` - Grouping variable
352- `order` - Order for categorical levels
353- `hue_order` - Order for hue levels
354- `orient` - "v" or "h"
355- `color` - Single color for boxes
356- `palette` - Color palette
357- `saturation` - Color saturation intensity
358- `width` - Width of boxes
359- `dodge` - Separate hue levels side-by-side
360- `fliersize` - Size of outlier markers
361- `linewidth` - Box line width
362- `whis` - IQR multiplier for whiskers (default: 1.5)
363- `notch` - Draw notched boxes
364- `showcaps` - Show whisker caps
365- `showmeans` - Show mean value
366- `meanprops` - Properties for mean marker
367- `boxprops` - Properties for boxes
368- `whiskerprops` - Properties for whiskers
369- `capprops` - Properties for caps
370- `flierprops` - Properties for outliers
371- `medianprops` - Properties for median line
372- `native_scale` - Use numeric scale
373- `formatter` - Formats categorical values, affecting both grouping and tick labels
374- `legend` - Whether to show legend
375- `ax` - Matplotlib axes
377**Example:**
378```python
379sns.boxplot(data=df, x='day', y='total_bill',
380 hue='smoker', palette='Set3',
381 showmeans=True, notch=True)
382```

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 - Formats categorical values, affecting both grouping and tick labels
  • 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)
Raw lines 344 to 383
384### violinplot()
386**Purpose:** Draw a violin plot combining boxplot and KDE.
388**Key Parameters:**
389Shares categorical mappings/order, color/palette, width/dodge/gap, native/log scales, formatter, legend and `ax`; box-specific `whis`, `notch`, `showmeans`, and box artist options do not apply. Additional parameters:
390- `bw_method` - KDE bandwidth method
391- `bw_adjust` - KDE bandwidth multiplier
392- `cut` - KDE extension beyond extremes
393- `density_norm` - "area", "count", "width"
394- `common_norm` - Normalize density across all violins in this axes-level call; do not assume independent facets share normalization
395- `inner` - "box", "quart", "point", "stick", None
396- `split` - Split violins for hue comparison
397- `inner_kws` - Additional parameters for interior artists
398- `gridsize` - KDE grid resolution
400**Example:**
401```python
402sns.violinplot(data=df, x='day', y='total_bill',
403 hue='sex', split=True, inner='quart',
404 density_norm='area', common_norm=False,
405 palette='muted')
406```

violinplot()

Purpose: Draw a violin plot combining boxplot and KDE.

Key Parameters: Shares categorical mappings/order, color/palette, width/dodge/gap, native/log scales, formatter, legend and ax; box-specific whis, notch, showmeans, and box artist options do not apply. Additional parameters:

  • bw_method - KDE bandwidth method
  • bw_adjust - KDE bandwidth multiplier
  • cut - KDE extension beyond extremes
  • density_norm - "area", "count", "width"
  • common_norm - Normalize density across all violins in this axes-level call; do not assume independent facets share normalization
  • inner - "box", "quart", "point", "stick", None
  • split - Split violins for hue comparison
  • inner_kws - Additional parameters for interior artists
  • gridsize - KDE grid resolution

Example:

sns.violinplot(data=df, x='day', y='total_bill',
               hue='sex', split=True, inner='quart',
               density_norm='area', common_norm=False,
               palette='muted')
Raw lines 384 to 407
408### boxenplot()
410**Purpose:** Draw enhanced box plot for larger datasets showing more quantiles.
412**Key Parameters:**
413Shares categorical mappings/order, color/palette, width/dodge/gap, native/log scales, formatter, legend and `ax`. Use `box_kws`, `line_kws`, and `flier_kws` for artist control; do not pass boxplot-only options. Additional parameters:
414- `k_depth` - "tukey", "proportion", "trustworthy", "full", or int
415- `outlier_prop` - Proportion of data as outliers
416- `trust_alpha` - Alpha for trustworthy depth
417- `width_method` - How box widths represent distribution: "exponential", "linear", "area"
418- `showfliers` - Show outlier points
420**Example:**
421```python
422sns.boxenplot(data=df, x='day', y='total_bill',
423 hue='time', width_method='area', palette='Set2')
424```

boxenplot()

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

Key Parameters: Shares categorical mappings/order, color/palette, width/dodge/gap, native/log scales, formatter, legend and ax. Use box_kws, line_kws, and flier_kws for artist control; do not pass boxplot-only options. Additional parameters:

  • k_depth - "tukey", "proportion", "trustworthy", "full", or int
  • outlier_prop - Proportion of data as outliers
  • trust_alpha - Alpha for trustworthy depth
  • width_method - How box widths represent distribution: "exponential", "linear", "area"
  • showfliers - Show outlier points

Example:

sns.boxenplot(data=df, x='day', y='total_bill',
              hue='time', width_method='area', palette='Set2')
Raw lines 408 to 425
426### barplot()
428**Purpose:** Draw a bar plot with error bars showing statistical estimates.
430**Key Parameters:**
431- `data` - DataFrame, array, or dict
432- `x, y` - Variables (one categorical, one continuous)
433- `hue` - Grouping variable
434- `order` - Order for categorical levels
435- `hue_order` - Order for hue levels
436- `estimator` - Aggregation function (default: mean)
437- `errorbar` - Error representation: "sd", "se", "pi", ("ci", level), ("pi", level), or None
438- `n_boot` - Bootstrap iterations
439- `seed` - Random seed
440- `units` - Identifier for sampling units
441- `weights` - Observation weights; only mean with CI or no error bars
442- `orient` - "v" or "h"
443- `color` - Single bar color
444- `palette` - Color palette
445- `saturation` - Color saturation
446- `width` - Bar width
447- `dodge` - Separate hue levels side-by-side
448- `err_kws` - Matplotlib keyword arguments for error bars
449- `capsize` - Error bar cap width
450- `native_scale` - Use numeric scale
451- `formatter` - Formats categorical values, affecting both grouping and tick labels
452- `legend` - Whether to show legend
453- `ax` - Matplotlib axes
455**Example:**
456```python
457sns.barplot(data=df, x='day', y='total_bill',
458 hue='sex', estimator='median',
459 errorbar=('ci', 95), capsize=0.1,
460 err_kws={'linewidth': 1.5})
461```

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; only mean with CI or no error bars
  • orient - "v" or "h"
  • color - Single bar color
  • palette - Color palette
  • saturation - Color saturation
  • width - Bar width
  • dodge - Separate hue levels side-by-side
  • err_kws - Matplotlib keyword arguments for error bars
  • capsize - Error bar cap width
  • native_scale - Use numeric scale
  • formatter - Formats categorical values, affecting both grouping and tick labels
  • 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,
            err_kws={'linewidth': 1.5})
Raw lines 426 to 462
463### countplot()
465**Purpose:** Show counts of observations in each categorical bin.
467**Key Parameters:**
468Shares categorical mappings/order, color/palette, width/dodge/gap, native/log scales, formatter, legend and `ax`.
469- Specify only x or y (the categorical variable)
470- No estimator, weights, units, bootstrap, or errorbar parameters
471- `stat` - "count", "percent", "probability", or "proportion"; normalized across the whole plot, not separately within each hue
473**Example:**
474```python
475sns.countplot(data=df, x='day', hue='time',
476 palette='pastel', dodge=True)
477```

countplot()

Purpose: Show counts of observations in each categorical bin.

Key Parameters: Shares categorical mappings/order, color/palette, width/dodge/gap, native/log scales, formatter, legend and ax.

  • Specify only x or y (the categorical variable)
  • No estimator, weights, units, bootstrap, or errorbar parameters
  • stat - "count", "percent", "probability", or "proportion"; normalized across the whole plot, not separately within each hue

Example:

sns.countplot(data=df, x='day', hue='time',
              palette='pastel', dodge=True)
Raw lines 463 to 478
479### pointplot()
481**Purpose:** Show point estimates and confidence intervals with connecting lines.
483**Key Parameters:**
484Shares mappings/order, estimator, errorbar, units, weights, seed/n_boot, native/log scales, formatter, legend and `ax`. It does not share bar geometry (`width`, `fill`, `gap`, `saturation`).
485- `markers`, `linestyles` - Marker/line styles, optionally one per hue
486- `markersize`, `linewidth` - Matplotlib artist sizes; replace deprecated `scale`
487- `linestyles="none"` - Disable connections; replaces deprecated `join=False`
488- `capsize`, `err_kws` - Error bar appearance
489- `dodge` - Boolean or numeric separation along the categorical axis
491**Example:**
492```python
493sns.pointplot(data=df, x='time', y='total_bill',
494 hue='sex', markers=['o', 's'],
495 linestyles=['-', '--'], capsize=0.1)
496```

pointplot()

Purpose: Show point estimates and confidence intervals with connecting lines.

Key Parameters: Shares mappings/order, estimator, errorbar, units, weights, seed/n_boot, native/log scales, formatter, legend and ax. It does not share bar geometry (width, fill, gap, saturation).

  • markers, linestyles - Marker/line styles, optionally one per hue
  • markersize, linewidth - Matplotlib artist sizes; replace deprecated scale
  • linestyles="none" - Disable connections; replaces deprecated join=False
  • capsize, err_kws - Error bar appearance
  • dodge - Boolean or numeric separation along the categorical axis

Example:

sns.pointplot(data=df, x='time', y='total_bill',
              hue='sex', markers=['o', 's'],
              linestyles=['-', '--'], capsize=0.1)
Raw lines 479 to 497
498### catplot()
500**Purpose:** Figure-level interface for categorical plots onto a FacetGrid.
502**Key Parameters:**
503Parameters for the selected categorical `kind`, except `ax`, plus:
504- `kind` - "strip", "swarm", "box", "violin", "boxen", "bar", "point", "count"
505- `col` - Categorical variable for column facets
506- `row` - Categorical variable for row facets
507- `col_wrap` - Wrap columns
508- `col_order` - Order for column facets
509- `row_order` - Order for row facets
510- `height` - Height of each facet
511- `aspect` - Aspect ratio
512- `sharex, sharey` - Share axes across facets
513- `legend` - Whether to show legend
514- `legend_out` - Place legend outside figure
515- `facet_kws` - Additional FacetGrid parameters
517**Example:**
518```python
519sns.catplot(data=df, x='day', y='total_bill',
520 hue='smoker', col='time',
521 kind='violin', split=True,
522 height=4, aspect=0.8)
523```

catplot()

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

Key Parameters: Parameters for the selected categorical kind, except ax, plus:

  • kind - "strip", "swarm", "box", "violin", "boxen", "bar", "point", "count"
  • 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
  • sharex, sharey - Share axes across facets
  • legend - Whether to show legend
  • legend_out - Place legend outside figure
  • facet_kws - Additional FacetGrid parameters

Example:

sns.catplot(data=df, x='day', y='total_bill',
            hue='smoker', col='time',
            kind='violin', split=True,
            height=4, aspect=0.8)
Raw lines 498 to 524
525## Regression Plots

Regression Plots

Raw lines 525 to 526
527### regplot()
529**Purpose:** Plot data and a linear regression fit.
531**Key Parameters:**
532- `data` - DataFrame
533- `x, y` - Variables or data vectors
534- `x_estimator` - Apply estimator to x bins
535- `x_bins` - Bin x for estimator
536- `x_ci` - CI for binned estimates
537- `scatter` - Show scatter points
538- `fit_reg` - Plot regression line
539- `ci` - CI for regression estimate (int or None)
540- `n_boot` - Bootstrap iterations for CI
541- `units` - Identifier for sampling units
542- `seed` - Random seed
543- `order` - Polynomial regression order
544- `logistic` - Fit logistic regression
545- `lowess` - Fit lowess smoother
546- `robust` - Fit robust regression
547- `logx` - Fit y against log(x), drawing in original coordinates; x must be positive
548- `x_partial, y_partial` - Partial regression (regress out variables)
549- `truncate` - Limit regression line to data range
550- `dropna` - Drop missing values
551- `x_jitter, y_jitter` - Add jitter to data
552- `label` - Label for legend
553- `color` - Color for all elements
554- `marker` - Marker style
555- `scatter_kws` - Parameters for scatter
556- `line_kws` - Parameters for regression line
557- `ax` - Matplotlib axes
559**Example:**
560```python
561sns.regplot(data=df, x='total_bill', y='tip',
562 order=2, ci=95, seed=7,
563 scatter_kws={'alpha': 0.5})
564```

regplot()

Purpose: Plot data and a linear regression fit.

Key Parameters:

  • data - DataFrame
  • x, y - Variables or data vectors
  • x_estimator - Apply estimator to x bins
  • x_bins - Bin x for estimator
  • x_ci - CI for binned estimates
  • scatter - Show scatter points
  • fit_reg - Plot regression line
  • ci - CI for regression estimate (int or None)
  • n_boot - Bootstrap iterations for CI
  • units - Identifier for sampling units
  • seed - Random seed
  • order - Polynomial regression order
  • logistic - Fit logistic regression
  • lowess - Fit lowess smoother
  • robust - Fit robust regression
  • logx - Fit y against log(x), drawing in original coordinates; x must be positive
  • x_partial, y_partial - Partial regression (regress out variables)
  • truncate - Limit regression line to data range
  • dropna - Drop missing values
  • x_jitter, y_jitter - Add jitter to data
  • label - Label for legend
  • color - Color for all elements
  • marker - Marker style
  • scatter_kws - Parameters for scatter
  • line_kws - Parameters for regression line
  • ax - Matplotlib axes

Example:

sns.regplot(data=df, x='total_bill', y='tip',
            order=2, ci=95, seed=7,
            scatter_kws={'alpha': 0.5})
Raw lines 527 to 565
566### lmplot()
568**Purpose:** Figure-level interface for regression plots onto a FacetGrid.
570**Key Parameters:**
571Selected regression options from `regplot()` (not `ax`, `label`, or arbitrary axis-level artist arguments), plus:
572- `hue` - Grouping variable
573- `col` - Column facets
574- `row` - Row facets
575- `palette` - Color palette
576- `col_wrap` - Wrap columns
577- `height` - Facet height
578- `aspect` - Aspect ratio
579- `markers` - Marker style(s)
580- `facet_kws={"sharex": ..., "sharey": ...}` - Share axes; top-level forms are deprecated
581- `hue_order` - Order for hue levels
582- `col_order` - Order for column facets
583- `row_order` - Order for row facets
584- `legend` - Whether to show legend
585- `facet_kws={"legend_out": ...}` - Legend position; top-level form is deprecated
586- `facet_kws` - FacetGrid parameters
588**Example:**
589```python
590sns.lmplot(data=df, x='total_bill', y='tip',
591 hue='smoker', col='time', row='sex',
592 height=3, aspect=1.2, ci=None)
593```

lmplot()

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

Key Parameters: Selected regression options from regplot() (not ax, label, or arbitrary axis-level artist arguments), plus:

  • hue - Grouping variable
  • col - Column facets
  • row - Row facets
  • palette - Color palette
  • col_wrap - Wrap columns
  • height - Facet height
  • aspect - Aspect ratio
  • markers - Marker style(s)
  • facet_kws={"sharex": ..., "sharey": ...} - Share axes; top-level forms are deprecated
  • hue_order - Order for hue levels
  • col_order - Order for column facets
  • row_order - Order for row facets
  • legend - Whether to show legend
  • facet_kws={"legend_out": ...} - Legend position; top-level form is deprecated
  • facet_kws - FacetGrid parameters

Example:

sns.lmplot(data=df, x='total_bill', y='tip',
           hue='smoker', col='time', row='sex',
           height=3, aspect=1.2, ci=None)
Raw lines 566 to 594
595### residplot()
597**Purpose:** Plot residuals of a regression.
599**Key Parameters:**
600Uses `data`, `x`, `y`, `x_partial`, `y_partial`, `order`, `robust`, `dropna`, `label`, `color`, `scatter_kws`, `line_kws`, and `ax`. It has no `ci`, `logistic`, or `logx` parameter.
601- Plots residuals (y - predicted) against x, not fitted values
602- Adds a horizontal line at y=0
603- `lowess=True` fits a smoother to residuals; requires statsmodels
605**Example:**
606```python
607sns.residplot(data=df, x='x', y='y', lowess=True,
608 scatter_kws={'alpha': 0.5})
609```

residplot()

Purpose: Plot residuals of a regression.

Key Parameters: Uses data, x, y, x_partial, y_partial, order, robust, dropna, label, color, scatter_kws, line_kws, and ax. It has no ci, logistic, or logx parameter.

  • Plots residuals (y - predicted) against x, not fitted values
  • Adds a horizontal line at y=0
  • lowess=True fits a smoother to residuals; requires statsmodels

Example:

sns.residplot(data=df, x='x', y='y', lowess=True,
              scatter_kws={'alpha': 0.5})
Raw lines 595 to 610
611## Matrix Plots
613### heatmap()
615**Purpose:** Plot rectangular data as a color-encoded matrix.
617**Key Parameters:**
618- `data` - 2D array-like data
619- `vmin, vmax` - Anchor values for colormap
620- `cmap` - Colormap name or object
621- `center` - Value at colormap center
622- `robust` - Use robust quantiles for colormap range
623- `annot` - Annotate cells: True, False, or array
624- `fmt` - Format string for annotations (e.g., ".2f")
625- `annot_kws` - Parameters for annotations
626- `linewidths` - Width of cell borders
627- `linecolor` - Color of cell borders
628- `cbar` - Draw colorbar
629- `cbar_kws` - Colorbar parameters
630- `cbar_ax` - Axes for colorbar
631- `square` - Force square cells
632- `xticklabels, yticklabels` - Tick labels (True, False, int, or list)
633- `mask` - Boolean array to mask cells
634- `ax` - Matplotlib axes
636**Example:**
637```python
638# Correlation matrix
639corr = df.select_dtypes(include='number').corr()
640mask = np.triu(np.ones_like(corr, dtype=bool))
641sns.heatmap(corr, mask=mask, annot=True, fmt='.2f',
642 cmap='coolwarm', center=0, square=True,
643 linewidths=1, cbar_kws={'shrink': 0.8})
644```

heatmap()

Purpose: Plot rectangular data as a color-encoded matrix.

Key Parameters:

  • data - 2D array-like data
  • vmin, vmax - Anchor values for colormap
  • cmap - Colormap name or object
  • center - Value at colormap center
  • robust - Use robust quantiles for colormap range
  • annot - Annotate cells: True, False, or array
  • fmt - Format string for annotations (e.g., ".2f")
  • annot_kws - Parameters for annotations
  • linewidths - Width of cell borders
  • linecolor - Color of cell borders
  • cbar - Draw colorbar
  • cbar_kws - Colorbar parameters
  • cbar_ax - Axes for colorbar
  • square - Force square cells
  • xticklabels, yticklabels - Tick labels (True, False, int, or list)
  • mask - Boolean array to mask cells
  • ax - Matplotlib axes

Example:

# Correlation matrix
corr = df.select_dtypes(include='number').corr()
mask = np.triu(np.ones_like(corr, dtype=bool))
sns.heatmap(corr, mask=mask, annot=True, fmt='.2f',
            cmap='coolwarm', center=0, square=True,
            linewidths=1, cbar_kws={'shrink': 0.8})
Raw lines 613 to 645
646### clustermap()
648**Purpose:** Plot a hierarchically-clustered heatmap.
650**Key Parameters:**
651Many heatmap styling parameters through `**kwargs`, but owns its figure/axes; do not pass `ax` or `cbar_ax`. Additional parameters:
652- `pivot_kws` - Parameters for pivoting (if needed)
653- `method` - Linkage method: "single", "complete", "average", "weighted", "centroid", "median", "ward"
654- `metric` - Distance metric for clustering
655- `standard_scale` - Min-max scale to [0, 1]: 0 (rows), 1 (columns), or None; distinct from z-scoring
656- `z_score` - Z-score normalize data: 0 (rows), 1 (columns), or None
657- `row_cluster, col_cluster` - Cluster rows/columns
658- `row_linkage, col_linkage` - Precomputed linkage matrices
659- `row_colors, col_colors` - Additional color annotations
660- `dendrogram_ratio` - Ratio of dendrogram to heatmap
661- `colors_ratio` - Ratio of color annotations to heatmap
662- `cbar_pos` - Colorbar position (tuple: x, y, width, height)
663- `tree_kws` - Parameters for dendrogram
664- `figsize` - Figure size
666**Example:**
667```python
668sns.clustermap(data, method='average', metric='euclidean',
669 z_score=0, cmap='viridis',
670 row_colors=row_colors, col_colors=col_colors,
671 figsize=(12, 12), dendrogram_ratio=0.1)
672```

clustermap()

Purpose: Plot a hierarchically-clustered heatmap.

Key Parameters: Many heatmap styling parameters through **kwargs, but owns its figure/axes; do not pass ax or cbar_ax. Additional parameters:

  • pivot_kws - Parameters for pivoting (if needed)
  • method - Linkage method: "single", "complete", "average", "weighted", "centroid", "median", "ward"
  • metric - Distance metric for clustering
  • standard_scale - Min-max scale to [0, 1]: 0 (rows), 1 (columns), or None; distinct from z-scoring
  • z_score - Z-score normalize data: 0 (rows), 1 (columns), or None
  • row_cluster, col_cluster - Cluster rows/columns
  • row_linkage, col_linkage - Precomputed linkage matrices
  • row_colors, col_colors - Additional color annotations
  • dendrogram_ratio - Ratio of dendrogram to heatmap
  • colors_ratio - Ratio of color annotations to heatmap
  • cbar_pos - Colorbar position (tuple: x, y, width, height)
  • tree_kws - Parameters for dendrogram
  • figsize - Figure size

Example:

sns.clustermap(data, method='average', metric='euclidean',
               z_score=0, cmap='viridis',
               row_colors=row_colors, col_colors=col_colors,
               figsize=(12, 12), dendrogram_ratio=0.1)
Raw lines 646 to 673
674## Multi-Plot Grids

Multi-Plot Grids

Raw lines 674 to 675
676### FacetGrid
678**Purpose:** Multi-plot grid for plotting conditional relationships.
680**Initialization:**
681```python
682g = sns.FacetGrid(data, row=None, col=None, hue=None,
683 col_wrap=None, sharex=True, sharey=True,
684 height=3, aspect=1, palette=None,
685 row_order=None, col_order=None, hue_order=None,
686 hue_kws=None, dropna=False, legend_out=True,
687 despine=True, margin_titles=False,
688 xlim=None, ylim=None, subplot_kws=None,
689 gridspec_kws=None)
690```
692**Methods:**
693- `map(func, *args, **kwargs)` - Apply function to each facet
694- `map_dataframe(func, *args, **kwargs)` - Apply function with full DataFrame
695- `set_axis_labels(x_var, y_var)` - Set axis labels
696- `set_titles(template, **kwargs)` - Set subplot titles
697- `set(**kwargs)` - Set attributes on all axes
698- `add_legend(legend_data, title, label_order, **kwargs)` - Add legend
699- `savefig(*args, **kwargs)` - Save figure
701**Example:**
702```python
703g = sns.FacetGrid(df, col='time', row='sex', hue='smoker',
704 height=3, aspect=1.5, margin_titles=True)
705g.map_dataframe(sns.scatterplot, x='total_bill', y='tip', alpha=0.7)
706g.add_legend()
707g.set_axis_labels('Total Bill ($)', 'Tip ($)')
708g.set_titles('{col_name} | {row_name}')
709```

FacetGrid

Purpose: Multi-plot grid for plotting conditional relationships.

Initialization:

g = sns.FacetGrid(data, row=None, col=None, hue=None,
                  col_wrap=None, sharex=True, sharey=True,
                  height=3, aspect=1, palette=None,
                  row_order=None, col_order=None, hue_order=None,
                  hue_kws=None, dropna=False, legend_out=True,
                  despine=True, margin_titles=False,
                  xlim=None, ylim=None, subplot_kws=None,
                  gridspec_kws=None)

Methods:

  • map(func, *args, **kwargs) - Apply function to each facet
  • map_dataframe(func, *args, **kwargs) - Apply function with full DataFrame
  • set_axis_labels(x_var, y_var) - Set axis labels
  • set_titles(template, **kwargs) - Set subplot titles
  • set(**kwargs) - Set attributes on all axes
  • add_legend(legend_data, title, label_order, **kwargs) - Add legend
  • savefig(*args, **kwargs) - Save figure

Example:

g = sns.FacetGrid(df, col='time', row='sex', hue='smoker',
                  height=3, aspect=1.5, margin_titles=True)
g.map_dataframe(sns.scatterplot, x='total_bill', y='tip', alpha=0.7)
g.add_legend()
g.set_axis_labels('Total Bill ($)', 'Tip ($)')
g.set_titles('{col_name} | {row_name}')
Raw lines 676 to 710
711### PairGrid
713**Purpose:** Grid for plotting pairwise relationships in a dataset.
715**Initialization:**
716```python
717g = sns.PairGrid(data, hue=None, vars=None,
718 x_vars=None, y_vars=None,
719 hue_order=None, palette=None,
720 hue_kws=None, corner=False,
721 diag_sharey=True, height=2.5,
722 aspect=1, layout_pad=0.5,
723 despine=True, dropna=False)
724```
726**Methods:**
727- `map(func, **kwargs)` - Apply function to all subplots
728- `map_diag(func, **kwargs)` - Apply to diagonal
729- `map_offdiag(func, **kwargs)` - Apply to off-diagonal
730- `map_upper(func, **kwargs)` - Apply to upper triangle
731- `map_lower(func, **kwargs)` - Apply to lower triangle
732- `add_legend(legend_data, **kwargs)` - Add legend
733- `savefig(*args, **kwargs)` - Save figure
735**Example:**
736```python
737g = sns.PairGrid(df, hue='species', vars=['a', 'b', 'c', 'd'],
738 corner=True, height=2.5)
739# corner=True omits upper-triangle axes
740g.map_lower(sns.kdeplot)
741g.map_diag(sns.histplot, kde=True)
742g.add_legend()
743```

PairGrid

Purpose: Grid for plotting pairwise relationships in a dataset.

Initialization:

g = sns.PairGrid(data, hue=None, vars=None,
                 x_vars=None, y_vars=None,
                 hue_order=None, palette=None,
                 hue_kws=None, corner=False,
                 diag_sharey=True, height=2.5,
                 aspect=1, layout_pad=0.5,
                 despine=True, dropna=False)

Methods:

  • map(func, **kwargs) - Apply function to all subplots
  • map_diag(func, **kwargs) - Apply to diagonal
  • map_offdiag(func, **kwargs) - Apply to off-diagonal
  • map_upper(func, **kwargs) - Apply to upper triangle
  • map_lower(func, **kwargs) - Apply to lower triangle
  • add_legend(legend_data, **kwargs) - Add legend
  • savefig(*args, **kwargs) - Save figure

Example:

g = sns.PairGrid(df, hue='species', vars=['a', 'b', 'c', 'd'],
                 corner=True, height=2.5)
# corner=True omits upper-triangle axes
g.map_lower(sns.kdeplot)
g.map_diag(sns.histplot, kde=True)
g.add_legend()
Raw lines 711 to 744
745### JointGrid
747**Purpose:** Grid for bivariate plot with marginal univariate plots.
749**Initialization:**
750```python
751g = sns.JointGrid(data=None, x=None, y=None, hue=None,
752 height=6, ratio=5, space=0.2,
753 dropna=False, xlim=None, ylim=None,
754 marginal_ticks=False, hue_order=None,
755 palette=None)
756```
758**Methods:**
759- `plot(joint_func, marginal_func, **kwargs)` - Plot both joint and marginals
760- `plot_joint(func, **kwargs)` - Plot joint distribution
761- `plot_marginals(func, **kwargs)` - Plot marginal distributions
762- `refline(x, y, **kwargs)` - Add reference line
763- `set_axis_labels(xlabel, ylabel, **kwargs)` - Set axis labels
764- `savefig(*args, **kwargs)` - Save figure
766**Example:**
767```python
768g = sns.JointGrid(data=df, x='x', y='y', hue='group',
769 height=6, ratio=5, space=0.2)
770g.plot_joint(sns.scatterplot, alpha=0.5)
771g.plot_marginals(sns.histplot, kde=True)
772g.set_axis_labels('Variable X', 'Variable Y')
773```

JointGrid

Purpose: Grid for bivariate plot with marginal univariate plots.

Initialization:

g = sns.JointGrid(data=None, x=None, y=None, hue=None,
                  height=6, ratio=5, space=0.2,
                  dropna=False, xlim=None, ylim=None,
                  marginal_ticks=False, hue_order=None,
                  palette=None)

Methods:

  • plot(joint_func, marginal_func, **kwargs) - Plot both joint and marginals
  • plot_joint(func, **kwargs) - Plot joint distribution
  • plot_marginals(func, **kwargs) - Plot marginal distributions
  • refline(x, y, **kwargs) - Add reference line
  • set_axis_labels(xlabel, ylabel, **kwargs) - Set axis labels
  • savefig(*args, **kwargs) - Save figure

Example:

g = sns.JointGrid(data=df, x='x', y='y', hue='group',
                  height=6, ratio=5, space=0.2)
g.plot_joint(sns.scatterplot, alpha=0.5)
g.plot_marginals(sns.histplot, kde=True)
g.set_axis_labels('Variable X', 'Variable Y')
Raw lines 745 to 774
775## Scientific constraints
777- In 0.13 categorical plots, statistics are computed in the transformed space when a log scale is active. A displayed mean can therefore be geometric rather than arithmetic; precompute the intended estimate when necessary.
779- `lineplot` removes missing rows before drawing: `estimator=None` alone does not preserve gaps. Split contiguous runs as in [patterns_and_troubleshooting.md](patterns_and_troubleshooting.md).
780- Choose one regression mode: `order>1`, `logistic`, `robust`, `lowess`, and `logx` are mutually exclusive. Lowess has no bootstrap CI; advanced fits require statsmodels. These are exploratory fits, not a substitute for a specified inference model.
781- KDE/violin bandwidth and support affect apparent modes. `cut=0` does not remove boundary bias. `common_norm=False` normalizes each underlying density separately, which hides sample-size differences; a truncated drawing need not integrate to one.
782- Correlations use pairwise-complete observations; inspect sample counts and constant columns. A heatmap does not imply significance or causation.
783- Clustering needs finite values; a heatmap mask does not make missing values valid clustering input. Reject zero-variance rows for `z_score=0` or zero-range rows for `standard_scale=0` (analogous for columns). Ward linkage requires Euclidean geometry. Choose scaling according to whether rows or features should be standardized, align annotation Series by labels, and save via the returned `ClusterGrid.savefig`.

Scientific constraints

  • In 0.13 categorical plots, statistics are computed in the transformed space when a log scale is active. A displayed mean can therefore be geometric rather than arithmetic; precompute the intended estimate when necessary.
  • lineplot removes missing rows before drawing: estimator=None alone does not preserve gaps. Split contiguous runs as in patterns_and_troubleshooting.md.
  • Choose one regression mode: order>1, logistic, robust, lowess, and logx are mutually exclusive. Lowess has no bootstrap CI; advanced fits require statsmodels. These are exploratory fits, not a substitute for a specified inference model.
  • KDE/violin bandwidth and support affect apparent modes. cut=0 does not remove boundary bias. common_norm=False normalizes each underlying density separately, which hides sample-size differences; a truncated drawing need not integrate to one.
  • Correlations use pairwise-complete observations; inspect sample counts and constant columns. A heatmap does not imply significance or causation.
  • Clustering needs finite values; a heatmap mask does not make missing values valid clustering input. Reject zero-variance rows for z_score=0 or zero-range rows for standard_scale=0 (analogous for columns). Ward linkage requires Euclidean geometry. Choose scaling according to whether rows or features should be standardized, align annotation Series by labels, and save via the returned ClusterGrid.savefig.
Raw lines 775 to 783