CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-seaborn

Statistical data visualization library for Python built on matplotlib

Pending
Overview
Eval results
Files

categorical-plots.mddocs/

Categorical Plots

Visualize distributions and statistical summaries for categorical data using strip plots, swarm plots, box plots, violin plots, bar plots, and count plots. These functions reveal patterns across categorical groups and provide statistical insights.

Capabilities

Figure-level Categorical Plotting

Create multi-panel figures with categorical plots across subsets of data.

def catplot(
    data,
    *,
    x=None,
    y=None,
    hue=None,
    row=None,
    col=None,
    col_wrap=None,
    estimator="mean",
    errorbar=("ci", 95),
    n_boot=1000,
    seed=None,
    order=None,
    hue_order=None,
    row_order=None,
    col_order=None,
    kind="strip",
    height=5,
    aspect=1,
    orient=None,
    color=None,
    palette=None,
    hue_norm=None,
    legend="auto",
    legend_out=True,
    sharex=True,
    sharey=True,
    margin_titles=False,
    facet_kws=None,
    **kwargs
):
    """
    Figure-level interface for drawing categorical plots onto a FacetGrid.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str, names of variables in data
    - hue: str, grouping variable for color mapping
    - row, col: str, variables for faceting into subplots
    - kind: str, plot type ("strip", "swarm", "box", "violin", "boxen", "point", "bar", "count")
    - estimator: str or callable, statistical function for bar/point plots
    - errorbar: str or tuple, error bar representation method
    - height: float, height of each facet in inches
    - aspect: float, aspect ratio of each facet
    
    Returns:
    FacetGrid object
    """

Strip Plots

Draw categorical scatter plots with non-overlapping points.

def stripplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    orient=None,
    color=None,
    palette=None,
    size=5,
    edgecolor="gray",
    linewidth=0,
    hue_norm=None,
    native_scale=False,
    formatter=None,
    legend="auto",
    ax=None,
    **kwargs
):
    """
    Draw a scatterplot where one variable is categorical.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables
    - hue: str, grouping variable for color mapping
    - order: list, order for categorical levels
    - size: float, marker size
    - edgecolor: str, marker edge color
    - native_scale: bool, use native scale for numeric categories
    
    Returns:
    matplotlib Axes object
    """

Swarm Plots

Draw categorical scatter plots with adjusted point positions to avoid overlap.

def swarmplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    orient=None,
    color=None,
    palette=None,
    size=5,
    edgecolor="gray",
    linewidth=0,
    hue_norm=None,
    native_scale=False,
    formatter=None,
    legend="auto",
    warn_thresh=0.05,
    ax=None,
    **kwargs
):
    """
    Draw a categorical scatterplot with points adjusted to be non-overlapping.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables
    - hue: str, grouping variable for color mapping
    - size: float, marker size
    - warn_thresh: float, threshold for warning about point overlap
    
    Returns:
    matplotlib Axes object
    """

Box Plots

Show distributions with quartiles, medians, and outliers.

def boxplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    orient=None,
    color=None,
    palette=None,
    saturation=0.75,
    fill=True,
    dodge="auto",
    width=0.8,
    gap=0,
    whis=1.5,
    linecolor="auto",
    linewidth=None,
    boxprops=None,
    whiskerprops=None,
    capprops=None,
    medianprops=None,
    flierprops=None,
    hue_norm=None,
    native_scale=False,
    formatter=None,
    legend="auto",
    ax=None,
    **kwargs
):
    """
    Draw a box plot to show distributions with respect to categories.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables
    - hue: str, grouping variable for color mapping
    - dodge: bool or "auto", separate hue levels along categorical axis
    - width: float, width of boxes
    - whis: float, whisker length as multiple of IQR
    - boxprops, whiskerprops, etc.: dict, styling properties
    
    Returns:
    matplotlib Axes object
    """

Violin Plots

Combine box plots with kernel density estimation to show full distributions.

def violinplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    orient=None,
    color=None,
    palette=None,
    saturation=0.75,
    fill=True,
    dodge="auto",
    width=0.8,
    gap=0,
    inner="box",
    split=False,
    linecolor="auto",
    linewidth=None,
    cut=2,
    gridsize=100,
    bw_method="scott",
    bw_adjust=1,
    density_norm="area",
    common_norm=False,
    hue_norm=None,
    formatter=None,
    legend="auto",
    ax=None,
    **kwargs
):
    """
    Draw a combination of boxplot and kernel density estimation.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables
    - hue: str, grouping variable for color mapping
    - inner: str, representation inside violins ("box", "quart", "point", "stick", None)
    - split: bool, split violins when hue nesting
    - cut: float, distance to extend density beyond data extremes
    - bw_method: str or scalar, bandwidth estimation method
    
    Returns:
    matplotlib Axes object
    """

Enhanced Box Plots

Draw enhanced box plots optimized for larger datasets.

def boxenplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    orient=None,
    color=None,
    palette=None,
    saturation=0.75,
    fill=True,
    dodge="auto",
    width=0.8,
    gap=0,
    linecolor=None,
    linewidth=None,
    width_method="exponential",
    k_depth="tukey",
    outlier_prop=0.007,
    trust_alpha=0.05,
    showfliers=True,
    hue_norm=None,
    native_scale=False,
    formatter=None,
    legend="auto",
    ax=None,
    **kwargs
):
    """
    Draw an enhanced box plot for larger datasets.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables
    - hue: str, grouping variable for color mapping
    - k_depth: str or int, number of boxes to draw
    - outlier_prop: float, proportion of data as outliers
    - showfliers: bool, whether to show outliers
    
    Returns:
    matplotlib Axes object
    """

Point Plots

Show point estimates and confidence intervals with connecting lines.

def pointplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    estimator="mean",
    errorbar=("ci", 95),
    n_boot=1000,
    seed=None,
    orient=None,
    color=None,
    palette=None,
    markers="o",
    linestyles="-",
    dodge=False,
    join=True,
    scale=1,
    hue_norm=None,
    native_scale=False,
    formatter=None,
    legend="auto",
    capsize=0,
    err_kws=None,
    ax=None,
    **kwargs
):
    """
    Show point estimates and confidence intervals using scatter plot glyphs.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables
    - hue: str, grouping variable for color mapping
    - estimator: str or callable, statistical function
    - errorbar: str or tuple, error bar representation method
    - markers: str or list, marker styles
    - linestyles: str or list, line styles for connections
    - join: bool, connect points with lines
    - scale: float, scaling factor for elements
    
    Returns:
    matplotlib Axes object
    """

Bar Plots

Show point estimates and confidence intervals as rectangular bars.

def barplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    estimator="mean",
    errorbar=("ci", 95),
    n_boot=1000,
    seed=None,
    orient=None,
    color=None,
    palette=None,
    saturation=0.75,
    fill=True,
    hue_norm=None,
    width=0.8,
    dodge="auto",
    gap=0,
    log_scale=None,
    native_scale=False,
    formatter=None,
    legend="auto",
    capsize=0,
    err_kws=None,
    ax=None,
    **kwargs
):
    """
    Show point estimates and confidence intervals as rectangular bars.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables
    - hue: str, grouping variable for color mapping
    - estimator: str or callable, statistical function
    - errorbar: str or tuple, error bar representation method
    - width: float, width of bars
    - dodge: bool or "auto", separate hue levels
    - capsize: float, cap width for error bars
    
    Returns:
    matplotlib Axes object
    """

Count Plots

Show counts of observations in categorical bins using bars.

def countplot(
    data=None,
    *,
    x=None,
    y=None,
    hue=None,
    order=None,
    hue_order=None,
    orient=None,
    color=None,
    palette=None,
    saturation=0.75,
    fill=True,
    hue_norm=None,
    stat="count",
    width=0.8,
    dodge="auto",
    gap=0,
    log_scale=None,
    native_scale=False,
    formatter=None,
    legend="auto",
    ax=None,
    **kwargs
):
    """
    Show the counts of observations in each categorical bin using bars.
    
    Parameters:
    - data: DataFrame, dict, or array of data
    - x, y: str or array-like, input data variables (one should be categorical)
    - hue: str, grouping variable for color mapping
    - stat: str, statistic to compute ("count" or "percent")
    - width: float, width of bars
    - dodge: bool or "auto", separate hue levels
    
    Returns:
    matplotlib Axes object
    """

Usage Examples

Strip Plot

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset("tips")

# Basic strip plot
sns.stripplot(data=tips, x="day", y="total_bill")
plt.show()

Box Plot with Grouping

# Box plot with hue grouping
sns.boxplot(data=tips, x="day", y="total_bill", hue="smoker")
plt.show()

Violin Plot

# Violin plot showing full distributions
sns.violinplot(data=tips, x="day", y="total_bill", inner="box")
plt.show()

Bar Plot with Confidence Intervals

# Bar plot showing means with confidence intervals
sns.barplot(data=tips, x="day", y="total_bill", estimator="mean")
plt.show()

Multi-Panel Categorical Plot

# Create subplots by smoker status
sns.catplot(
    data=tips,
    x="day", y="total_bill",
    col="smoker", kind="box"
)
plt.show()

Install with Tessl CLI

npx tessl i tessl/pypi-seaborn

docs

categorical-plots.md

color-palettes.md

distribution-plots.md

grid-plots.md

index.md

interactive-widgets.md

matrix-plots.md

objects-interface.md

relational-plots.md

styling-themes.md

utilities.md

tile.json