可以使用'geom_path' 函数来绘制连接点的线条,使首尾相连。以下是一个示例代码:

library(ggplot2)

# 创建数据
x <- c(1, 2, 3, 4, 5)
y <- c(1, 3, 2, 4, 5)
df <- data.frame(x, y)

# 绘制点线图
ggplot(df, aes(x, y)) +
  geom_point() +
  geom_path() +
  xlim(0, 6) +
  ylim(0, 6) +
  theme_classic()

运行以上代码会生成一个点线图,并且首尾相连的线条将连结起来。

R语言绘制点线图:首尾相连

原文地址: https://www.cveoy.top/t/topic/lQgr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录