我有两组时间序列数据。我想将它们绘制在一个图中。此外,绘图应该在 -3 到 15 的 y 轴的固定比例下显示 a 和 b,其中 x 轴是时间和日期,y 轴是 v1。
数据 a : TimeAndDate v1
1 2007-09-30 00:00:00 0.3460000
2 2007-09-30 01:00:00 0.1660000
3 2007-09-30 02:00:00 0.2066667
4 2007-09-30 03:00:00 0.2956667
5 2007-09-30 04:00:00 0.2220000
6 2007-09-30 05:00:00 0.6090000
7 2007-09-30 06:00:00 0.8480000
8 2007-09-30 07:00:00 1.1986667
9 2007-09-30 08:00:00 1.4696667
10 2007-09-30 09:00:00 1.6280000
数据 b:TimeAndDate v1
1 2007-09-29 00:00:00 -1.3250000
2 2007-09-29 01:00:00 -0.4670000
3 2007-09-29 02:00:00 -0.4426667
4 2007-09-29 03:00:00 -0.6396667
5 2007-09-29 04:00:00 -0.7843333
6 2007-09-29 05:00:00 -0.5563333
7 2007-09-29 06:00:00 -0.7276667
8 2007-09-29 07:00:00 -0.6260000
9 2007-09-29 08:00:00 -0.7290000
10 2007-09-29 09:00:00 0.4976667
预期成绩:
我已通过代码将数据合并为 temp:
temp <- data.frame(HMn29_29$avg_val,HMn28_29$avg_val,HMn29_29$h)
HMn29_29.avg_val HMn28_29.avg_val HMn29_29.h
1 -1.3250000 -1.9225000 2007-09-29 00:00:00
2 -0.4670000 -1.6676667 2007-09-29 01:00:00
3 -0.4426667 -1.5820000 2007-09-29 02:00:00
4 -0.6396667 -1.5716667 2007-09-29 03:00:00
5 -0.7843333 -1.8290000 2007-09-29 04:00:00
6 -0.5563333 -1.6153333 2007-09-29 05:00:00
7 -0.7276667 -1.8093333 2007-09-29 06:00:00
8 -0.6260000 -1.9303333 2007-09-29 07:00:00
9 -0.7290000 -1.3980000 2007-09-29 08:00:00
10 0.4976667 1.2270000 2007-09-29 09:00:00
情节代码:
ggplot(temp, aes( HMn29_29.h)) +
+ geom_line(aes(y = HMn28_29.avg_val, colour = "var0")) +
+ geom_line(aes(y = HMn29_29.avg_val, colour = "var1"))
如何将 y 轴固定为 -3 到 15?