gpt4 book ai didi

r - 在单个图中绘制多个表

转载 作者:行者123 更新时间:2023-12-02 02:08:30 27 4
gpt4 key购买 nike

我有 11 个时间序列,其中包括一个温度列。换句话说,有 11 个表格应显示在一个图中,线条颜色或线条类型不同。

  t1      t2      t3      t4      t5      t6      t7       t8     t9      t10      t11
4.14 4.12 4.09 4.07 4.14 4.14 4.12 4.09 4.07 5.70 42.67
4.01 3.99 3.97 3.94 4.01 4.01 3.99 3.97 3.94 4.14 39.98
3.89 3.86 3.84 3.82 3.89 3.89 3.86 3.84 3.82 4.01 38.73
3.77 3.74 3.72 3.69 3.77 3.77 3.74 3.72 3.69 3.89 37.50
3.64 3.62 3.59 3.57 3.64 3.64 3.62 3.59 3.57 3.77 36.25
3.52 3.50 3.48 3.45 3.52 3.52 3.50 3.48 3.45 3.64 35.07
3.40 3.38 3.35 3.33 3.40 3.40 3.38 3.35 3.33 3.52 33.86
3.27 3.24 3.22 3.19 3.27 3.27 3.24 3.22 3.19 3.40 32.52
3.13 3.10 3.07 3.05 3.13 3.13 3.10 3.07 3.05 3.27 31.11
2.99 2.96 2.94 2.91 2.99 2.99 2.96 2.94 2.91 3.13 29.73
2.85 2.81 2.78 2.75 2.85 2.85 2.81 2.78 2.75 2.99 28.23
2.69 2.66 2.63 2.59 2.69 2.69 2.66 2.63 2.59 2.85 26.69
2.53 2.49 2.46 2.42 2.53 2.53 2.49 2.46 2.42 2.69 25.01
2.36 2.33 2.29 2.26 2.36 2.36 2.33 2.29 2.26 2.53 23.36
2.19 2.16 2.13 2.10 2.19 2.19 2.16 2.13 2.10 2.36 21.74
2.05 2.02 1.98 1.95 2.05 2.05 2.02 1.98 1.95 2.19 20.24

最佳答案

一个选项是:

  1. 使用 melt reshape 数据
  2. ggplot2 绘制熔化数据

     dat$date <- seq(as.Date('2011-01-01'),as.Date('2011-01-31'),
    length.out=dim(dat)[1])
    library(reshape2)
    dat.m <- melt(dat,id='date')
    library(ggplot2)
    qplot(data=subset(dat.m),x= date, y=value,color=variable, geom='line')

enter image description here

我从数据集中删除了 t11 变量并重新绘制

     qplot(data=subset(dat.m, variable != 't11'),x= date, y=value,
color=variable, geom='line')

enter image description here

关于r - 在单个图中绘制多个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13841328/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com