折线图1

有两个连续变量(数值变量)时,可以通过作出折线图来观察两个变量之间的关系。


载入R包。


library(ggplot2)


创建作图数据。


mydata <- data.frame(
  months = 1:6,
  height = c(122355)
)

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()


▌欢迎关注公众号:R语言和统计
▌课程相关咨询可添加R师妹微信: kefu_rstats
▌邮箱:contact@rstats.cn
▌网站:www.rstats.cn
我们致力于让R语言和统计变得简单!




2023-02-21 16:28
首页    ggplot2    折线图1