Statistical data visualization library for Python built on matplotlib
npx @tessl/cli install tessl/pypi-seaborn@0.13.0A comprehensive statistical data visualization library for Python built on top of matplotlib that provides a high-level interface for creating attractive and informative statistical graphics. Seaborn offers specialized plotting functions for statistical relationships, categorical data visualization, distribution analysis, and matrix visualizations with intelligent default styling, color palette management, and seamless integration with pandas DataFrames.
pip install seabornimport seaborn as snsCommon pattern with matplotlib:
import seaborn as sns
import matplotlib.pyplot as pltimport seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
# Load built-in dataset
tips = sns.load_dataset("tips")
# Create a simple scatter plot
sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time")
plt.show()
# Create a regression plot
sns.regplot(data=tips, x="total_bill", y="tip")
plt.show()
# Set seaborn theme for better styling
sns.set_theme(style="whitegrid")Seaborn provides two complementary plotting interfaces:
relplot, catplot, displot)scatterplot, boxplot, histplot)The library integrates seamlessly with matplotlib for customization and pandas for data handling, making it ideal for statistical analysis workflows.
Visualize relationships between variables using scatter plots, line plots, and regression analysis with support for semantic groupings and multi-panel layouts.
def relplot(data, x, y, hue=None, style=None, size=None, kind="scatter", **kwargs): ...
def scatterplot(data, x, y, hue=None, style=None, size=None, **kwargs): ...
def lineplot(data, x, y, hue=None, style=None, size=None, **kwargs): ...
def regplot(data, x, y, **kwargs): ...
def lmplot(data, x, y, hue=None, **kwargs): ...
def residplot(data, x, y, **kwargs): ...Display categorical data through strip plots, swarm plots, box plots, violin plots, bar plots, and count plots with statistical summaries and confidence intervals.
def catplot(data, x, y, hue=None, kind="strip", **kwargs): ...
def stripplot(data, x, y, hue=None, **kwargs): ...
def swarmplot(data, x, y, hue=None, **kwargs): ...
def boxplot(data, x, y, hue=None, **kwargs): ...
def violinplot(data, x, y, hue=None, **kwargs): ...
def barplot(data, x, y, hue=None, estimator=None, **kwargs): ...
def countplot(data, x, hue=None, **kwargs): ...Analyze and visualize statistical distributions using histograms, kernel density estimation, empirical CDFs, and rug plots with univariate and bivariate support.
def displot(data, x, y=None, hue=None, kind="hist", **kwargs): ...
def histplot(data, x, y=None, hue=None, **kwargs): ...
def kdeplot(data, x, y=None, hue=None, **kwargs): ...
def ecdfplot(data, x, hue=None, **kwargs): ...
def rugplot(data, x, y=None, **kwargs): ...Create heatmaps and clustered heatmaps for correlation matrices, pivot tables, and hierarchical clustering visualization.
def heatmap(data, **kwargs): ...
def clustermap(data, **kwargs): ...Build complex multi-panel figures with FacetGrid, PairGrid, and JointGrid for comprehensive data exploration and comparison across subsets.
class FacetGrid:
def __init__(self, data, **kwargs): ...
def map(self, func, *args, **kwargs): ...
class PairGrid:
def __init__(self, data, **kwargs): ...
def map(self, func, **kwargs): ...
def pairplot(data, **kwargs): ...
def jointplot(data, x, y, kind="scatter", **kwargs): ...Configure plot aesthetics, themes, color palettes, and plotting contexts with extensive customization options for publication-quality graphics.
def set_theme(context="notebook", style="darkgrid", palette="deep", **kwargs): ...
def set_style(style, rc=None): ...
def set_context(context, font_scale=1, rc=None): ...
def set_palette(palette, n_colors=None, desat=None): ...
def color_palette(palette=None, n_colors=None, desat=None): ...
def reset_defaults(): ...
def reset_orig(): ...Generate and customize color palettes including sequential, diverging, qualitative, and perceptually uniform palettes with built-in colormap support.
def husl_palette(n_colors=6, h=0.01, s=0.9, l=0.65): ...
def cubehelix_palette(n_colors=6, start=0, rot=0.4, gamma=1.0, hue=0.8, light=0.85, dark=0.15): ...
def dark_palette(color, n_colors=6, reverse=False, as_cmap=False): ...
def light_palette(color, n_colors=6, reverse=False, as_cmap=False): ...
def diverging_palette(h_neg, h_pos, s=75, l=50, n=6, center="light"): ...Essential utility functions for plot customization, data loading, color manipulation, and legend management.
def despine(fig=None, ax=None, top=True, right=True, left=False, bottom=False): ...
def load_dataset(name, cache=True, data_home=None, **kwargs): ...
def move_legend(obj, loc, **kwargs): ...
def get_dataset_names(): ...Interactive Jupyter widgets for creating and customizing color palettes in real-time with GUI controls for palette selection and parameter adjustment.
def choose_colorbrewer_palette(data_type, as_cmap=False): ...
def choose_dark_palette(input="husl", as_cmap=False): ...
def choose_light_palette(input="husl", as_cmap=False): ...
def choose_diverging_palette(as_cmap=False): ...
def choose_cubehelix_palette(as_cmap=False): ...Declarative, object-oriented interface for creating statistical graphics following Grammar of Graphics principles with composable classes for flexible visualization construction.
class Plot:
def __init__(self, *args, data=None, **variables): ...
def add(self, mark, *transforms, **kwargs): ...
def facet(self, col=None, row=None, **kwargs): ...
def scale(self, **scales): ...
# Mark classes
class Dot(Mark): ...
class Line(Mark): ...
class Bar(Mark): ...
# Statistical transforms
class Hist(Stat): ...
class KDE(Stat): ...
class Agg(Stat): ...
# Positional adjustments
class Jitter(Move): ...
class Dodge(Move): ...
class Stack(Move): ...Core types used throughout the seaborn API:
# Data input types
DataFrame = pandas.DataFrame
Series = pandas.Series
Array = numpy.ndarray | list
# Color specifications
ColorSpec = str | tuple | list # Color names, hex codes, RGB tuples
PaletteSpec = str | list | dict # Palette names or color lists
# Plot objects
FacetGrid = seaborn.axisgrid.FacetGrid
PairGrid = seaborn.axisgrid.PairGrid
JointGrid = seaborn.axisgrid.JointGrid