Data Visualization
Visualization translates data into graphics to reveal patterns, trends, and anomalies that numbers alone obscure.
Definition
matplotlib is the low-level foundation: plt.plot(), plt.scatter(), plt.hist() give fine-grained control over every element.
seaborn builds on matplotlib with statistical plots: sns.boxplot(), sns.pairplot(), sns.heatmap(corr) with built-in styling.
Intuition
The right chart type depends on what you're showing: scatter for relationships, bars for categories, lines for time series, histograms for distributions.
Good visualizations reduce cognitive load — the viewer should grasp the key takeaway in seconds.
Worked example
sns.scatterplot(data=df, x="income", y="spending", hue="segment") reveals how spending varies by income and segment.
sns.histplot(df["age"], kde=True) shows the distribution of ages with an overlaid density curve.
The math
matplotlib uses a figure-canvas-axes hierarchy: fig, ax = plt.subplots(); ax.plot(x, y) adds data to the axes.
seaborn's Relationalplot, Categoricalplot, and Distributionplot offer structured interfaces for common chart families.
In practice
Use visualizations to validate assumptions (normality, linearity), spot outliers, and communicate findings to non-technical audiences.
Exploratory visualizations guide feature engineering and model selection before any modeling begins.
Go deeper
More in Data science
Assembled from the ReLU.chat curated knowledge base. These explanations are concise on purpose; check the sources for anything important.