How to Create a Scatterplot in R with Multiple Variables?
In this article, we will be looking at the way to create a scatter plot with multiple variables in the R programming language.
Using Plot() And Points() Function In Base R:
In this approach to create a scatter plot with multiple variables, the user needs to call the plot() function
- Plot() function: This is a generic function for the plotting of R objects.
plot(x, y, …)
- x: the x coordinates of points in the plot.
- y: the y coordinates of points in the plot
Points() function: It is a generic function to draw a sequence of points at the specified coordinates
points(x,y = NULL, type = “p”, …)
- x, y: coordinate vectors of points to plot.
- type: character indicating the type of plotting; actually any of the types as in plot.default.
- …: Further graphical parameters may also be supplied as arguments.
In this example, we will be creating a scatter plot of 2 different variables using the plot() and the point() function in the R programming language.
Here, we will be creating a scatter plot of 4 different variables.
Here, we will be creating a scatter plot of 6 different variables.