Creating a Scatter Plot using the Plot function
Scatter plots are useful for visualizing the relationship between two variables. Let’s create a simple scatter plot using the plot() function.
# Create example data
x <- c(1, 2, 3, 4, 5)
y <- c(2, 3, 5, 4, 6)
# Create a scatter plot
plot(x, y, main = "Scatter Plot", xlab = "X-axis", ylab = "Y-axis",
col = "blue", pch = 19)
Output:
In this example, we create two vectors x and y representing data points. We then use the plot() function to create a scatter plot, specifying the main title, axis labels, point color (col), and point shape (pch).
Plot Function In R
Data visualization is a crucial aspect of data analysis, allowing us to gain insights and communicate findings effectively. In R, the plot() function is a versatile tool for creating a wide range of plots, including scatter plots, line plots, bar plots, histograms, and more. In this article, we’ll explore the plot() function in R Programming Language with multiple examples to showcase its capabilities.