Python / Data Science Essentials Interview Questions
What is Seaborn and how does it differ from Matplotlib?
Seaborn is a high-level statistical visualisation library built on top of Matplotlib. Where Matplotlib gives you full control over every pixel, Seaborn provides opinionated, attractive defaults and plot types designed specifically for statistical exploration — with far less boilerplate code.
| Aspect | Matplotlib | Seaborn |
|---|---|---|
| Level | Low-level — explicit control | High-level — declarative |
| Defaults | Functional but plain | Publication-quality themes out of the box |
| DataFrame integration | Manual (extract arrays) | Direct — pass df= and column names |
| Statistical plots | Manual calculation required | Built-in (regression, KDE, violin, pair) |
| Customisation | Unlimited | Matplotlib calls needed for fine-tuning |
import seaborn as sns
import matplotlib.pyplot as plt
# Load a built-in example dataset
tips = sns.load_dataset('tips')
# Seaborn: one line to create a scatter with regression line and hue
sns.regplot(data=tips, x='total_bill', y='tip')
# Matplotlib equivalent would require:
# 1. Compute regression manually
# 2. Plot scatter
# 3. Plot fitted line
# 4. Shade confidence interval — ~15 lines total
# Themes and contexts
sns.set_theme(style='whitegrid', context='notebook', palette='muted')
# styles: darkgrid, whitegrid, dark, white, ticks
# contexts: paper, notebook, talk, poster (scale font/line sizes)Seaborn plots return Matplotlib Axes objects, so all standard Matplotlib customisation still applies after the Seaborn call: ax = sns.scatterplot(...); ax.set_title('My Title'). Seaborn does not replace Matplotlib — it is a complement that handles the tedious parts of statistical plotting.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
