首先,需要安装并加载绘图包 "ggplot2"。
install.packages("ggplot2")
library(ggplot2)
然后,使用函数 ggplot()
创建绘图对象,并使用函数 geom_point()
绘制点。
ggplot(data = data, aes(x = x, y = y)) +
geom_point()
其中,data
是一个数据框,其中包含两列 x
和 y
,分别表示点的横纵坐标。
首先,需要安装并加载绘图包 "ggplot2"。
install.packages("ggplot2")
library(ggplot2)
然后,使用函数 ggplot()
创建绘图对象,并使用函数 geom_point()
绘制点。
ggplot(data = data, aes(x = x, y = y)) +
geom_point()
其中,data
是一个数据框,其中包含两列 x
和 y
,分别表示点的横纵坐标。