1
0
This commit is contained in:
Steven Hobs
2025-08-20 12:08:09 +08:00
commit ad8ef460d6
7 changed files with 133 additions and 0 deletions

24
src/test-plot.R Normal file
View File

@@ -0,0 +1,24 @@
# 设置随机种子以便重现
set.seed(123)
# 生成示例数据
x <- rnorm(100) # 生成 100 个正态分布随机数作为 x 值
y <- rnorm(100) # 生成 100 个正态分布随机数作为 y 值
# 创建散点图
plot(x, y,
main = "Scatter Plot of Random Data", # 图表标题
xlab = "X-axis Label", # X 轴标签
ylab = "Y-axis Label", # Y 轴标签
col = "blue", # 点的颜色
pch = 19
) # 点的形状
# 添加回归线
abline(lm(y ~ x), col = "red") # 添加线性回归线,红色
# 添加图例
legend("topright",
legend = c("Data Points", "Regression Line"),
col = c("blue", "red"), pch = c(19, NA), lty = c(NA, 1)
)