Create a Plot Matrix of Scatterplots in R Programming - pairs() Function Last Updated : 10 Dec, 2021 Comments Improve Suggest changes Like Article Like Report pairs() function in R language is used to return a plot matrix, consisting of scatter plots corresponding to each data frame. R - Create Plot Matrix of Scatterplots Syntax: pairs(data) Parameters: data: It is defined as value of pairs Plot. Returns: Color, Labels, Panels, and by Group in pairs plot. Create Plot Matrix of Scatterplots in RExample 1: Basic example of R - pairs() Function R # Set seed for reproducibility set.seed(425340) # Sample size of 800 N <- 800 # Create variable x1 <- rnorm(N) # Create correlated variable x2 <- x1 + rnorm(N, 0, 4) # Create another correlated variable x3 <- 2 * x1 - x2 + rnorm(N, 0, 3) data <- data.frame(x1, x2, x3) pairs(data) Output: Here, in the above example, the diagonal shows the names of the three numeric variables. The middle graphic in the first-row shows the relation between x1 and x2 whereas the right graph in the first row shows the relation between x1 and x3 and so on. Example 2: Another example to select Variables of pairs Plot R # Set seed for reproducibility set.seed(425340) # Sample size of 800 N <- 800 # Create variable x1 <- rnorm(N) # Create correlated variable x2 <- x1 + rnorm(N, 0, 4) # Create another correlated variable x3 <- 2 * x1 - x2 + rnorm(N, 0, 3) data <- data.frame(x1, x2, x3) pairs(~ x1 + x3, data = data) Output: Example 3: Another example with implementation to Modify Color, Shape of Points, Labels and Title R # Set seed for reproducibility set.seed(425340) # Sample size of 800 N <- 800 # Create variable x1 <- rnorm(N) # Create correlated variable x2 <- x1 + rnorm(N, 0, 4) # Create another correlated variable x3 <- 2 * x1 - x2 + rnorm(N, 0, 3) data <- data.frame(x1, x2, x3) pairs(~ x1 + x2 + x3, data = data) pairs(~ x1 + x3, data = data) pairs(data[, 1:3], col = "darkgreen", # Change color pch = 18, # Change shape of points # Change labels of diagonal labels = c("var1", "var2", "var3"), main = " pairs plot in R") Output: Comment More infoAdvertise with us Next Article Create a Plot Matrix of Scatterplots in R Programming - pairs() Function K kaurbal1698 Follow Improve Article Tags : R Language R Plot-Function Similar Reads Create a Matrix of Scatterplots (pairs() Equivalent) in ggplot2 Visualizing relationships between multiple variables simultaneously can be challenging. In base R, the pairs() function is often used to create a matrix of scatterplots, showing pairwise relationships between all columns in a data frame. However, for those who prefer the flexibility and aesthetics o 3 min read Addition of more points to a Plot in R Programming - points() Function points() function in R Language is used to add a group of points of specified shapes, size and color to an existing plot. Syntax: points(x, y, cex, pch, col) Parameters: x, y: Vector of coordinates cex: size of points pch: shape of points col: color of points Sample Scatter Plot: Python3 1== # R pro 2 min read Addition of Lines to a Plot in R Programming - lines() Function In R, the lines() function is called to add on top of already existing plot. This is particularly helpful when you want to add more lines, such as trend lines, regression lines, or special lines, on a plot. The lines() function allows flexibility in line color, line width, and line type, with multip 3 min read Create a Heatmap in R Programming - heatmap() Function A heatmap() function in R Programming Language is used to plot a heatmap. A heatmap is defined as a graphical representation of data using colors to visualize the value of the matrix. It is used to represent more common values or higher activities brighter colors reddish colors are used and to less 3 min read Plotting of Data using Generic plots in R Programming - plot() Function In this article, we will discuss how we plot data using Generic plots in R Programming Language using plot() Function. plot functionplot() function in R Programming Language is defined as a generic function for plotting. It can be used to create basic graphs of a different type. Syntax: plot(x, y, t 5 min read Like