Seaborn vs Matplotlib
Matplotlib vs Seaborn (simple comparison)
Matplotlib
- Low-level building blocks
- Maximum control
- More code required for common charts
Seaborn
- High-level statistical plots
- Beautiful defaults
- Works naturally with DataFrames
In practice, you often use both together:
- Seaborn creates the plot
- Matplotlib is used to customize labels, titles, and layout
flowchart LR A["DataFrame"] --> B["sns.barplot / boxplot / etc.
(the statistical chart)"] B --> C["plt.title / xlabel / ylabel
(Matplotlib finishing touches)"] C --> D["plt.tight_layout(); plt.show()"]
Example: same idea, different style
Matplotlib
Matplotlib
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [10, 6, 8, 4]
plt.plot(x, y, marker="o")
plt.title("Matplotlib line")
plt.xlabel("x")
plt.ylabel("y")
plt.tight_layout()
plt.show()Matplotlib
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [10, 6, 8, 4]
plt.plot(x, y, marker="o")
plt.title("Matplotlib line")
plt.xlabel("x")
plt.ylabel("y")
plt.tight_layout()
plt.show()Seaborn
Seaborn
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="whitegrid")
x = [1, 2, 3, 4]
y = [10, 6, 8, 4]
sns.lineplot(x=x, y=y, marker="o")
plt.title("Seaborn line")
plt.xlabel("x")
plt.ylabel("y")
plt.tight_layout()
plt.show()Seaborn
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="whitegrid")
x = [1, 2, 3, 4]
y = [10, 6, 8, 4]
sns.lineplot(x=x, y=y, marker="o")
plt.title("Seaborn line")
plt.xlabel("x")
plt.ylabel("y")
plt.tight_layout()
plt.show()Rule of thumb
- Use Seaborn for quick exploration (EDA)
- Use Matplotlib for fine-grained control or custom layouts
Good habit
Even when using Seaborn, always add:
- Title
- Axis labels
- Reasonable figure size
- Tight layout
Next
Continue to Distribution Plots (displot, histplot) to start exploring how a single numeric variable is spread out.
🧪 Try It Yourself
Exercise 1 – Switch the Seaborn Theme
Exercise 2 – Same Data, Two Libraries
Exercise 3 – Pick the Right Tool
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
