This article about the plot function in R Language gives some introduction about the plot() function, the use and purpose of its arguments, and a few examples are provided. Using the R plot function one can draw different graphical representations and the arguments of the plot() function can be used to enhance the graph.

**Question:** Can we draw graphics in R language?**Answer:** Yes. R language produces high-quality statistical graphs. There are many useful and sophisticated kinds of graphs available in R.

**Question:** Where graphics are displayed in R?**Answer:** In R, all graphs are produced in a window named Graphic Windows which can be resized.

**Question:** What is the use of the plot function in R?**Answer:** In R, plot() is a generic function that can be used to make a variety of point and line graphs. plot() function can also be used to define a coordinate space.

### Important Arguments of the Plot Function in R

**Question:** What are the arguments of the plot() function?**Answer:** There are many arguments used in the plot() function. Some of these arguments are x, y, type, xlab, ylab, etc. To see the full list of arguments of the plot() write the command in the R console;

args(plot.default)

**Question:** Are all arguments necessary to be used in R?**Answer:** No. The first two arguments x and y provide the horizontal and vertical coordinates of points or lines to be plotted and define a data-coordinate system for the graph. At least argument x is required. Note that many of the arguments are set to default values in the plot function.

**Question:** What is the use of the argument type in the plot() function?**Answer:** In the R plot function, the argument type determines the type of the graph to be drawn. Several types of graphs can be drawn. The default type of graph type=’p’, plots points at the coordinates specified by the x and y argument. Specifying type=’l’ produces a line graph, and type=’n’ sets up the plotting region to accommodate the data set but plots nothing.

**Question:** Are there other types of graphs?

Answer: Yes. Setting type=’b’, draw graphs having both points and lines. Setting type=’h’ draws histogram-like vertical lines and setting type=’s’ and type=’S’ draws stair-step-like lines starting horizontally and vertically respectively.

**Question:** What is the use of xlim and ylim in plot() function?

Answer: The arguments xlim and ylim may be used to define the limits of the horizontal and vertical axes. Usually, these arguments are unnecessary, because R language reasonably picks limits from x and y.

**Question:** What are the purpose of xlab and xlab arguments in the plot() function?**Answer:** xlab and ylab argument tack character-string arguments to label the horizontal and vertical axes.

### Examples of R Plot Function in R

**Question:** Provide a few examples of the R plot function.**Answer:** The following are a few examples of R plot functions. Suppose you have a data set on variables x and y, such as

x <- rnorm(100, m=10, sd=10) y <- rnorm(100) plot(x, y) plot(x, y, xlab='XÂ (Mean=10, SD=10)',Â Â ylab='Y (Mean=1, SD=1)' , type='l') plot(x, y, xlab='XÂ (Mean=10, SD=10)',Â Â ylab='Y (Mean=1, SD=1)' , type='o') plot(x, y, xlab='XÂ (Mean=10, SD=10)',Â Â ylab='Y (Mean=1, SD=1)' , pch=10)