Matplotlib is the foundational Python plotting library: it gives you low-level control over every element of a figure. Seaborn is built on top of Matplotlib and adds a high-level interface for statistical graphics, with better default styles and direct support for pandas DataFrames. Use Seaborn for quick, good-looking statistical plots, and Matplotlib when you need full control or plot types Seaborn does not cover. In practice you use both together, because every Seaborn plot is a Matplotlib figure underneath.
Matplotlib provides the figure, axes, lines, text and rendering backends. Seaborn calls Matplotlib to draw, and its functions return Matplotlib Axes objects (or a FacetGrid that wraps several of them). That means you can start a plot with Seaborn and then fine-tune titles, limits, ticks and annotations with Matplotlib calls.
Install both with pip install matplotlib seaborn pandas. Current Seaborn releases require a recent Python 3 and depend on Matplotlib, NumPy and pandas, so check the Seaborn installation page for the minimum versions on your setup.
| Aspect | Matplotlib | Seaborn |
|---|---|---|
| Level | Low-level, object-oriented plotting toolkit | High-level statistical interface |
| Default look | Plain, needs styling | Modern themes and color palettes |
| Data input | Arrays and lists, DataFrame columns by hand | DataFrames with column names (data=, x=, y=, hue=) |
| Statistical plots | Possible, more code | Built in (box, violin, regression, distribution, heatmap, pair plots) |
| Aggregation and confidence intervals | You compute them | Often computed automatically |
| Customization | Complete control | Good, and falls back to Matplotlib |
| Plot types beyond statistics | Very broad (3D, polar, images, animation) | Focused on statistical plots |
With Matplotlib you build the figure explicitly:
With Seaborn you pass a DataFrame and column names, and it applies a theme:
Notice that import matplotlib.pyplot as plt is still needed to show the figure. The original examples of this kind often forget that import in the Seaborn version, which raises a NameError.
A box plot per group with colors by category is a few lines in Seaborn because it groups and summarises the data for you.
Passing hue="group" with legend=False colors each box without a redundant legend; in Seaborn 0.13 and later, passing a palette without hue is deprecated, so this is the current pattern.
The Matplotlib version needs you to split the data into lists yourself:
The tick_labels argument was introduced in Matplotlib 3.9; older versions use labels=, which is deprecated in newer ones.
Seaborn also offers histplot, kdeplot, violinplot, regplot, heatmap, pairplot and figure-level functions such as relplot, displot and catplot that create faceted grids with a col= or row= argument.
Because Seaborn returns Matplotlib objects, you can mix freely:
Use sns.set_theme() once at the top of a script to apply a consistent look to every Matplotlib figure that follows, including ones you draw with plain Matplotlib calls.
savefig.Yes. Seaborn depends on Matplotlib, and installing Seaborn with pip also installs it for you.
No. Seaborn adds a layer of computation and drawing on top of Matplotlib, so it is the same speed or slower. Its benefit is less code and better defaults, not performance.
Seaborn works best with pandas DataFrames, but many functions also accept NumPy arrays and lists through the x= and y= arguments.
Seaborn only draws; call plt.show() in a script or save with plt.savefig(). In Jupyter the figure displays automatically.
Seaborn is a statistical layer on top of Matplotlib. It reduces code for common statistical charts and gives good defaults, while Matplotlib gives complete control and broader plot types. Learn both: start with Seaborn for speed, and drop down to Matplotlib for the details.