Create a Basic Pairs Plot
A pairs plot creates a scatterplot for every pair of numeric variables.
R Graphics · Pairs Plot
Use matrix scatterplots, groups, correlations, custom panels, transformations, and selected variables.
Pairs plots show every pairwise relationship in a numeric data set. They support rapid multivariate screening for association, nonlinearity, clusters, and unusual observations.
A pairs plot creates a scatterplot for every pair of numeric variables.

Start with a small, relevant variable set; too many columns produce tiny panels and cognitive overload.
pairs(iris[, 1:4], pch = 19,
col = adjustcolor("#2563eb", .45), main = "Iris measurements")Group colors reveal clusters and differences across every pairwise relationship.

Map factor levels to a restrained palette and add a legend outside or within an unused panel.
cols <- c("#2563eb", "#0891b2", "#f59e0b")[iris$Species]
pairs(iris[, 1:4], pch = 19, col = adjustcolor(cols, .6))Correlation coefficients summarize linear association alongside the raw scatterplots.

A custom upper panel can print coefficients while the lower panels preserve the observations.
panel.cor <- function(x, y, ...) {
usr <- par("usr"); on.exit(par(usr)); par(usr = c(0, 1, 0, 1))
text(.5, .5, format(cor(x, y), digits = 2), cex = 1.4)
}
pairs(iris[, 1:4], upper.panel = panel.cor, pch = 19, col = "#2563eb")Smooth curves reveal nonlinear pairwise patterns that a coefficient may miss.

panel.smooth adds a lowess curve to each scatterplot while retaining the original points.
pairs(mtcars[, c("mpg", "disp", "hp", "wt")],
lower.panel = panel.smooth, pch = 19,
col = adjustcolor("#2563eb", .5))Diagonal histograms add the marginal distribution of every variable.

Custom diagonal panels make the display more informative without changing the pairwise panels.
panel.hist <- function(x, ...) {
usr <- par("usr"); on.exit(par(usr)); par(usr = c(usr[1:2], 0, 1.5))
h <- hist(x, plot = FALSE); rect(h$breaks[-length(h$breaks)], 0, h$breaks[-1], h$counts/max(h$counts), col = "#93c5fd")
}
pairs(iris[, 1:4], diag.panel = panel.hist, pch = 19)A focused matrix keeps only variables relevant to the analytical question.

Selection is often the strongest design improvement: fewer panels allow larger marks, labels, and patterns.
vars <- mtcars[, c("mpg", "hp", "wt", "qsec")]
pairs(vars, pch = 21, bg = "#60a5fa", col = "white",
main = "Performance and efficiency")