Registry / data / seaborn

seaborn

JSON →
library0.13.2pypypi✓ verified 25d ago

Seaborn is a high-level Python library for creating statistical graphics, building on Matplotlib and integrating closely with Pandas data structures. It provides a dataset-oriented API to draw attractive and informative statistical plots with ease. The library is actively maintained with regular minor and major releases, currently at version 0.13.2, ensuring compatibility with evolving data science ecosystems.

pip install seaborn
INSTALL
IMPORT
SIG · SEABORN
S
seaborn
datapythonv0.13.2
Install
11.8s avg
Import
3793ms
Disk
258MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.13.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 3.948s · 254.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 11.8s · import 3.638s · 243MB
258MB installed
● package 258MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

seaborn
import seaborn as sns
The standard and widely adopted alias for Seaborn.
seaborn.objects
import seaborn.objects as so
Recommended alias for the experimental declarative 'objects' interface introduced in v0.12.0.

This quickstart demonstrates loading a built-in dataset, applying a theme, and creating a relational scatter plot using Seaborn's high-level API. It also includes basic Matplotlib calls for customization and displaying the plot.

import seaborn as sns import matplotlib.pyplot as plt sns.set_theme(style="darkgrid") # Load an example dataset tips = sns.load_dataset("tips") # Create a scatter plot sns.scatterplot( data=tips, x="total_bill", y="tip", hue="smoker", style="time", size="size" ) plt.title("Total Bill vs. Tip by Smoker and Time") plt.xlabel("Total Bill ($)") plt.ylabel("Tip ($)") plt.show()
Debug
Known issues
breakingThe `seaborn.objects` interface was introduced in v0.12.0, offering a new declarative API. While powerful, it's considered experimental and may have breaking changes or rough edges in early minor releases.
fix
Consult the official `seaborn.objects` documentation for specific usage and known limitations. For simpler plots or existing code, continue using the traditional axes-level and figure-level functions.
affects: >=0.12.0
breakingSeaborn's categorical plotting functions (e.g., `boxplot`, `barplot`, `catplot`) underwent a major overhaul in v0.13.0. This includes changes to color defaults (now requiring explicit `hue` for multiple colors) and the introduction of the `native_scale` parameter.
fix
Review code using categorical plots. To reproduce previous color behavior, explicitly assign a redundant `hue` variable (e.g., `boxplot(data, x='x', y='y', hue='x')`). If mixing categorical and numerical data on an axis, consider `native_scale=True`.
affects: >=0.13.0
deprecatedPython 3.7 support was dropped in Seaborn v0.12.2.
fix
Upgrade to Python 3.8 or newer to ensure compatibility and receive future updates.
affects: >=0.12.2
gotchaPositional arguments for most plotting functions were deprecated in v0.11.0 and enforced to be keyword-only in v0.12.0. This applies to arguments like `x`, `y`, `hue`, etc.
fix
Always pass arguments like `x`, `y`, `data` using explicit keywords (e.g., `sns.scatterplot(data=df, x='col1', y='col2')` instead of `sns.scatterplot(df, 'col1', 'col2')`).
affects: >=0.12.0
gotchaA regression in v0.13.0 caused exceptions when working with non-NumPy data types (e.g., Pandas nullable dtypes), which was fixed in v0.13.1. Pandas dtypes can still sometimes cause issues as Matplotlib (and by extension, Seaborn) often expects NumPy dtypes.
fix
Update to Seaborn v0.13.1 or later. Ensure that data passed to Seaborn plotting functions are of appropriate (usually numerical) NumPy types, converting Pandas nullable dtypes explicitly if necessary (e.g., `.astype(float)`).
affects: 0.13.0
gotchaWhen combining categorical plots with other plot types (e.g., a bar plot and a line plot on the same axes), misalignment can occur because categorical plots internally map string/category values to integer indices.
fix
For Seaborn v0.13.0+, use `native_scale=True` in categorical plots if the categorical axis truly represents numeric or datetime data. For older versions or string categories, carefully manage axis limits and tick labels using Matplotlib to ensure alignment.
affects: all
gotchaThe test environment generated warnings or notices from `pip` related to running as the root user or an available update for `pip`. These are typically environment-specific messages from the package manager, not direct failures of the tested library.
fix
It is generally recommended to run `pip` in a virtual environment to avoid permission issues and system conflicts. To update `pip`, run `pip install --upgrade pip`. If running as root is intentional and understood, use `pip --root-user-action=ignore` to suppress the warning.
affects: all
Errors
Common errors & fixes
AttributeError: 'AxesSubplot' object has no attribute 'distplot'
The `distplot` function (or its replacements like `histplot` and `kdeplot`) is a top-level function in the `seaborn` module, not a method directly callable on a Matplotlib Axes object.
fix
Call `sns.distplot()` directly, passing the `ax` parameter if you want to draw on a specific axes, or use the recommended `sns.histplot` or `sns.kdeplot` which support the `ax` parameter directly.
ValueError: cannot convert float NaN to integer
This error commonly occurs in `seaborn.heatmap` when `annot=True` is used with a format string for integers (e.g., `fmt='d'`) while the underlying data contains `NaN` (Not a Number) values, which are floats and cannot be directly converted to integers.
fix
Handle `NaN` values by either filling them (e.g., `df.fillna(0)`) or using a float format string (e.g., `fmt='.1f'` or `fmt='g'`) with `annot=True`, or set `annot=False` if annotations are not strictly needed.
TypeError: kdeplot got an unexpected keyword argument 'shade'
The `shade` parameter in `seaborn.kdeplot` was deprecated and subsequently removed in Seaborn versions 0.11.0 and later, replaced by the `fill` parameter.
fix
Replace `shade=True` with `fill=True` when calling `sns.kdeplot`.
AttributeError: 'FacetGrid' object has no attribute 'set_title'
Figure-level functions in Seaborn (like `sns.relplot`, `sns.catplot`, `sns.displot`, `sns.FacetGrid`) return a `FacetGrid` object, which is not a Matplotlib Axes object and thus does not have a `set_title` method; titles need to be set differently for figure-level plots.
fix
Use the `g.fig.suptitle()` method for an overall figure title, or `g.set_titles()` to set titles for individual subplots within the `FacetGrid`.
Upgrade
Version history
0.13.2latest on PyPI · released Jan 25, 2024
Audit
Dependencies
numpyrequiredMandatory dependency for numerical operations.
pandasrequiredMandatory dependency, closely integrated for data structures (DataFrames).
matplotlibrequiredMandatory dependency, Seaborn builds on top of Matplotlib for plotting.
scipyoptionalRequired for some advanced statistical functionality.
statsmodelsoptionalRequired for some advanced statistical functionality, particularly regression plots.
Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
1
Resources