The **plot()** function is used to draw points in R. The function takes parameters for specifying points in the diagram. Parameter 1 specifies points on the x-axis. Parameter 2 specifies points on the y-axis. Here's an example to plot two numbers against each other: $$\textbf{plot(1, 3)}$$ Draw one point in the diagram, at position (1) and position (3). To draw more points, use vectors: $$\textbf{plot(c(1, 8), c(3, 10))}$$ Draw two points in a diagram, one at position (1,3) and one in position (8,10) You can plot as many points as you like, just make sure you have the same number of points on both axis. Example: $$\textbf{plot(c(1, 2, 3, 4, 5), c(3, 7, 8, 9, 12))}$$ For better organization, when you have many values, it is better to use variables: $$\textbf{x $<-$ c(1, 2, 3, 4, 5)}$$ $$\textbf{y $<-$ c(3, 7, 8, 9, 12)}$$ $$\textbf{plot(x, y)}$$ If you want to draw dots in a sequence, on both the x-axis and the y-axis, use the "**:**" operator. Example: $$\textbf{plot(1:10)}$$ The plot() function also accepts other parameters, such as **main**, **xlab**, and **ylab**, if you want to customize the graph with a main title and different labels for the x and y-axis. Example: $$\textbf{plot(1:10, main="My Graph", xlab="The x-axis", ylab="The y axis")}$$ There are many other parameters you can use to change the appearance of the points. Use **col="color"** to add color to the points. Example:$$\textbf{plot(1:10, col="red")}$$ Use **cex=number** to change the size of the points (1 is the default, while 0.5 means 50\% smaller, and 2 means 100\% larger). Example: $$\textbf{plot(1:10, cex=2).}$$ Use **pch** with a value from 0 to 25 to change the point shape format. Example: $$\textbf{plot(1:10, pch=25, cex=2)}$$ The values of the **pch** parameter ranges from 0 to 25, which means that we can choose up to 26 different types of point shapes. The **plot()** function also takes a **type** parameter with the value l to draw a line to connect all the points. Example $$\textbf{plot(1:10, type="l")}$$ To change the width of the line, use the **lwd** parameter (1 is the default, while 0.5 means 50\% smaller, and 2 means 100\% larger). Example: $$\textbf{plot(1:10, type="l", lwd=2).}$$ The line is solid by default. Use the **lty** parameter with a value from 0 to 6 to specify the line format. For example, **lty=3** will display a dotted line instead of a solid line. Example:$$\textbf{plot(1:10, type="l", lwd=5, lty=3)}$$ To display more than one line in a graph, use the **plot()** function together with the **lines()** function. Example: $$\textbf{line1 $<-$ c(1,2,3,4,5,10)}$$ $$\textbf{line2 $<-$ c(2,5,7,8,9,10)}$$ $$\textbf{plot(line1, type = "l", col = "blue")}$$ $$\textbf{lines(line2, type="l", col = "red")}$$ A **Scatter plot** is a type of plot used to display the relationship between two numerical variables, and plots one dot for each observation. It needs two vectors of the same length, one for the x-axis (horizontal) and one for the y-axis (vertical). Example: $$\textbf{x $<-$ c(5,7,8,7,2,2,9,4,11,12,9,6)}$$ $$\textbf{y $<-$ c(99,86,87,88,111,103,87,94,78,77,85,86)}$$ $$\textbf{plot(x, y)}$$ Use the **pie()** function to draw Pie Charts. To create the vector of the pie chart $$ x <- c(10,20,30,40) $$ To display the pie chart$$\textbf{pie(x)}$$ Use the **label** parameter to add a label to the pie chart, and use the **main** parameter to add a header. Example: To create a vector of pies: $$\textbf{x $<-$ c(10,20,30,40)}$$ To create a vector of labels: $$\textbf{mylabel $<-$ c(""Apples"", "Bananas", "Cherries", "Dates")}$$ To display the pie chart with labels $$\textbf{pie(x, label = mylabel, main = "Fruits")}$$ Use the **barplot()** function to draw a vertical **Bar Chart.** Example: $$\textbf{x $<-$ c("A", "B", "C", "D")}$$ $$\textbf{y $<-$ c(2, 4, 6, 8)}$$ $$\textbf{barplot(y, names.arg = x)}$$ In the above example The x variable represents values in the x-axis (A,B,C,D), The y variable represents values in the y-axis (2,4,6,8), Then we use the barplot() function to create a bar chart of the values, **names.arg** defines the names of each observation on the x-axis. To change the bar texture, use the density parameter. Example: $$\textbf{x $<-$ c("A", "B", "C", "D")}$$ $$\textbf{y $<-$ c(2, 4, 6, 8)}$$ $$\textbf{barplot(y, names.arg = x, density = 10)}$$ To create a \textbf{Histogram}, use the \textbf{hist()} function: $$\textbf{x $<-$ rnorm(1000)}$$$$\textbf{hist(x)}$$ **These are just a few examples of the types of plots that can be created in R. There are many other types of plots and customization options available.**