How to create a scatter plot in R programming language?

In R language, you can use the plot() function to create a scatter plot. Here is a basic example:

# 创建数据集
x <- c(1, 2, 3, 4, 5)
y <- c(2, 3, 5, 7, 6)

# 绘制散点图
plot(x, y, main="Scatter Plot", xlab="X-axis", ylab="Y-axis", pch=19, col="blue")

The plot() function in the code above is used to create a scatter plot. x and y represent the datasets to be plotted, main sets the title of the graph, xlab and ylab set the labels for the x and y axes, pch determines the shape of the data points, and col sets their color. You can adjust these parameters based on your preferences to create scatter plots with different styles.

广告
Closing in 10 seconds
bannerAds