Typing Stubs for Seaborn
types-seaborn is a type stub package providing static type annotations for the popular Seaborn statistical data visualization library. It allows type checkers (like MyPy or Pyright) to verify code that uses Seaborn, improving code quality and catching potential errors during development. This package is part of the broader typeshed project, and its current version, 0.13.2.20260408, aims to provide accurate annotations for seaborn==0.13.2.
Warnings
- gotcha types-seaborn is solely a type stub package. Installing it does not provide the Seaborn library's functionality. You must install the actual 'seaborn' package separately to use the library at runtime.
- breaking Type annotations provided by 'types-seaborn' are specific to a particular version of the 'seaborn' library. Mismatches between the installed 'types-seaborn' version and the 'seaborn' library version can lead to incorrect or missing type hints, causing type checkers to report errors or fail to detect issues.
- gotcha Contributions and bug fixes for 'types-seaborn' should not be directed to a dedicated 'types-seaborn' repository. As part of the typeshed project, all improvements to these stubs must be contributed to the main typeshed GitHub repository.
Install
-
pip install types-seaborn -
pip install seaborn matplotlib pandas numpy
Imports
- seaborn
import seaborn as sns
- matplotlib.pyplot
import matplotlib.pyplot as plt
- pandas
import pandas as pd
Quickstart
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd # Often used with seaborn
# Apply the default seaborn theme for aesthetics
sns.set_theme()
# Load an example dataset provided by seaborn
tips = sns.load_dataset("tips")
# Create a relational plot
sns.relplot(
data=tips,
x="total_bill",
y="tip",
col="time",
hue="smoker",
style="smoker",
size="size"
)
plt.title("Tips by Total Bill, Time, and Smoker Status")
plt.show()