Visualizing Relationships and Correlations
Finding how variables relate is a core part of analysis. This topic shows the main charts for studying relationships between columns and how to read them with care.
a. Scatter Plots with Regression Lines
A scatter plot with a regression line shows both the individual points and the overall trend. Seaborn makes this easy with regplot and lmplot.
sns.regplot(data=tips, x="total_bill", y="tip")
sns.lmplot(data=tips, x="total_bill", y="tip", hue="smoker")The line shows the best straight-line fit, and the shaded band shows the uncertainty around it. A narrow band means more confidence in the trend.
Use lmplot when you want to draw separate lines for groups. This can reveal that the relationship is different in each group.
b. Correlation Heatmaps
A correlation heatmap shows the correlation between every pair of numeric columns in one grid. Colors represent the strength and direction. It gives a fast overview of which variables move together.
corr = df.corr(numeric_only=True)
sns.heatmap(corr, annot=True, cmap="coolwarm", center=0, fmt=".2f")Use a diverging palette centered on zero, so that positive and negative values have different colors. The annot=True option prints the numbers in each cell.
For large grids, show only the lower triangle with a mask, since the upper half repeats the same values.
c. Pair Plots and Joint Plots
A pair plot creates a grid of scatter plots for every pair of columns, with the distribution of each column on the diagonal. It is a quick first look at many relationships at once.
sns.pairplot(tips, hue="sex")
sns.jointplot(data=tips, x="total_bill", y="tip", kind="hex")A joint plot shows a relationship between two variables along with the distribution of each one on the sides. The kind option can be scatter, hex, kde, or reg.
Use pair plots on a handful of columns. With many columns, the grid becomes too big to read.
d. Reading Correlation Charts Correctly
A correlation value runs from negative 1 to 1. Values near 1 mean the variables rise together, values near negative 1 mean one rises as the other falls, and values near 0 mean no straight-line relationship.
Correlation does not prove cause. Ice cream sales and sunburns rise together because of hot weather, not because one causes the other. Always think about hidden factors.
Correlation also measures only straight-line relationships. A curved relationship can have a low correlation value even when the link is strong. Always check a scatter plot to see the true shape.
Data Visualization Tutorial
Wesline Rinisha








