折线图1
有两个连续变量(数值变量)时,可以通过作出折线图来观察两个变量之间的关系。
载入R包。
library(ggplot2)
创建作图数据。
mydata <- data.frame(
months = 1:6,
height = c(1, 2, 2, 3, 5, 5)
)
mydata
画出一个基本的。
ggplot(mydata, aes(months, height)) +
geom_line()
简单修饰。
ggplot(mydata, aes(months, height)) +
geom_line(size = 1, linetype = 1, colour = "cadetblue3") +
geom_point(size = 2, colour = "cadetblue") +
theme_classic()
2023-02-21 16:28