我有这个时间序列:
-0.0924141759
-2.0590256739
-1.0276440625
-1.5616938475
0.3205981119
1.6654641294
-1.8544074013
0.191729068
0.3256387062
0.8502480208
0.1760110767
-0.6563473838
-0.3053916378
0.3769501471
-0.9809580382
-2.0797045002
-0.1313354011
1.6628248241
-0.8906574373
0.9431893125
0.5804256085
-0.1455986083
-0.5977527101
-0.8137280583
0.2258726571
0.3200250425
0.5946214122
-0.0405850482
-0.8478119746
-0.5279590193
-0.0562429289
0.5976616178
-1.2205627588
0.1011648833
0.0814330849
-0.0633897372
1.1475753729
-0.5663064183
-1.3112647905
0.6907268696
1.0349986064
-0.1455737857
0.4439372806
1.2454731589
-0.7437021295
-0.2846497145
0.1941833223
-0.204275472
0.3957628815
-1.3392931852
-0.1082839345
-0.5085591956
0.682576211
1.8671730803
-0.7893753442
0.6477424753
0.0158389617
-0.2208581741
0.6333230992
-0.3556778869
-0.0967310897
-1.3783702014
-0.6963339031
1.5807720785
0.5604349562
2.6035854414
-0.091735153
0.2527786639
-0.1534329781
0.8612353413
0.4389897986
1.6438035697
1.062094995
1.5767447601
-1.5769353041
1.2547937726
-0.8800648341
0.4280591608
0.4541831875
2.0108818301
0.2599729369
0.6161732694
-0.6481358163
1.1855167619
-0.3630206871
-0.6367000425
-0.8992966922
-0.1274656555
2.2095699882
0.2921400893
-1.3287857685
0.2410802833
-0.112745189
0.10207581
-0.0976215944
1.1155549547
-2.4026408606
0.6998256509
-1.2757285255
-1.2806021086
-0.4730493151
-0.1036779129
-0.4446014626
-0.894070796
-0.8622455741
1.2227578553
-0.9891737794
0.9963447821
0.666495193
0.1050223579
-1.2287851496
0.0441687805
1.285684235
-1.1407726525
0.0547607503
-0.451247547
0.3944070638
-2.2262782054
0.3017539405
-0.7819613573
-1.6215007912
0.9685359576
0.3340272742
1.5077522883
-0.610629373
-1.1003778446
-0.0321910311
-1.7214777766
-1.8712992356
-1.9300330153
-1.813034438
0.1185035895
1.6638132366
-0.2788729673
0.9986974977
-1.8250003364
0.8529022704
0.6309471054
-0.7400320964
0.2313054745
0.3002270564
0.4309190538
1.2371105127
0.4087523052
0.0954851511
-0.7973750563
0.6796331883
-2.3699932278
0.8251383278
-0.7466198569
-1.2256526347
-0.3985482732
1.0426333481
-0.2160117609
-2.0395649409
-0.2848356997
-0.1605192633
0.1671641879
0.1590809809
1.1711333124
-1.581289946
0.5370777102
1.0974050184
1.220363168
-0.0259652912
-0.8691020799
-0.8723050617
-1.3266917607
-0.1941436035
0.2017996713
-0.2931475531
1.7125395584
-0.3649785306
0.1366490977
1.0712335649
0.0901637408
0.434546466
0.611308464
-1.5568846558
-0.4944924237
-1.7891389918
0.5715129799
-0.454855074
-0.0181358875
0.5079426999
-0.2869237313
-0.239707692
-1.0715695599
0.4328581602
-0.5301138112
-0.2001524765
0.4492632705
0.7046088768
1.346687571
1.4286924937
-1.1660037649
1.2088597664
-0.3633719356
0.3873582944
0.7450277543
0.5871424311
-1.0375503835
-0.6146190074
-0.6395468653
0.9050458728
0.25143693
0.9068159041
1.5723838825
-0.7085193358
-0.1517929192
-1.1487403013
-0.9370766493
0.1365614306
-0.2215338824
-2.8320316791
2.075447038
-0.3568782745
0.8794747818
0.6021644453
0.1756147457
1.1142080916
0.7015298023
0.2204610314
1.2474183766
-2.2733257717
0.5822141379
-1.1736265106
0.7840136043
0.500802451
1.5888741504
-1.5377504274
-1.0648829188
-0.5260960426
-0.7583351364
0.9204926043
0.2013089686
-0.1516615279
-0.740633493
-0.3559709932
-0.1714427455
-2.3922695402
0.3510468907
1.6331774077
0.7166216405
1.4110181998
-0.5735234212
-0.126875787
-0.6641524443
-0.8789345597
-1.792704449
-1.1872325367
-0.6163005981
0.0646188031
0.023782094
-0.5260802031
0.288174906
-0.5085358781
0.2178043386
0.2250944759
-1.005870766
-0.7378900509
0.3393923896
-0.4061763816
-2.2275824827
0.5113471881
-0.2556568247
-1.1903645168
0.592237176
-0.0414558195
0.1021655699
0.496253585
0.0631671452
0.4048986512
-1.0571128623
-1.1705702639
-0.0396848393
-1.4756755159
0.4610627651
0.411476842
0.0340363601
0.7478228463
0.2685899022
-0.2122767439
0.6591260365
0.363293436
-0.3309226348
0.0750842939
0.2742261452
-0.0123051487
-1.7513355616
-0.3421456868
-1.8181659105
0.7828090578
1.0393186612
-1.4013750974
-1.7099240637
-0.7288773614
0.0885042127
-1.0964741417
-0.0525929552
-0.2809465628
0.5096689251
-0.3791353453
-0.2700387127
0.64656642
0.7494409729
0.8775235875
-0.6777569026
1.5746296513
0.932147965
-1.1113873562
0.3066366992
-1.486750791
-0.4353943136
0.6181178354
0.8946119248
-1.0966411774
0.1857746145
-0.2074256874
0.555707172
-0.6576267203
-1.471747691
-0.2563668589
0.3634382683
0.1096610067
0.7339646352
-2.5134017659
0.1179208135
-1.2738159344
-0.8073365715
-1.0278623635
0.9740234161
0.7986605022
-0.1403022161
-0.1208519925
1.684480718
-0.7305069104
-0.888808085
0.6120289917
1.4989151464
0.6641275366
-0.1763707595
-0.550281902
-0.2440593277
0.5074607685
-0.0287898328
0.5245642146
-0.7384211888
-1.0874534507
-0.1667077246
-0.7043295426
0.5569664371
0.1761095287
0.2848076848
-1.2611971955
0.2027173843
0.4289449372
-0.103142197
0.464392291
0.7046473048
-1.2021740314
-1.462877779
-0.840011064
-1.2543010527
0.9644550356
0.4335269269
-0.3874265129
-0.0295691566
-0.4367742024
0.3963334919
0.1987519575
0.9263386856
-0.3894355005
-1.7842098141
-1.410699472
-0.3253857117
-0.3394460352
0.3887368951
0.9282564881
-0.618067843
-0.0528595934
-1.1056060536
-0.6115416766
-1.0518650748
0.3683766048
-0.6734679319
0.9791010573
0.4620552276
-0.6223159216
-0.4303123451
-1.1909881667
-0.9494944783
-0.2242879749
-0.3542384501
-0.5298012927
0.8974958044
0.5365546517
1.7515149922
0.1332193058
-0.3877207289
-0.1201422929
2.1014126844
1.5152519718
0.2501343565
0.8795863274
-0.1736124757
0.14838798
1.0656064384
1.1534511591
0.5319753344
1.1152060838
0.1831521398
0.0361966587
-0.4638001926
0.9660501847
-0.9614728591
-0.1763556861
-0.9439693847
-0.2723526807
-0.6042030943
1.6289316874
1.3824768439
-0.4221015461
-0.5178536015
0.3232376943
-0.5476832785
-1.4299494442
0.3353244278
-0.1163263085
-0.0850972429
0.7441083298
-1.2236138934
0.0910785595
0.5381932664
0.1981424355
-1.513213355
0.4621727207
0.0700248076
-0.4923376489
-0.2597078982
-0.7110180859
0.6320254817
0.3826036001
0.1519460573
1.9767759108
-2.2747022168
-0.0036416389
0.4599516692
0.9616349886
-0.2316836263
0.2809518668
1.5372429749
0.5250900664
0.4389184234
-0.0941350848
-0.0827508602
0.7814441527
0.9052933695
1.7425752563
-0.2108786609
0.4048866065
-0.6645599748
0.4910874979
0.8260018362
0.8485569533
-0.5129107422
0.5078965497
-0.9357996994
2.7322416997
1.4719669187
1.257844136
-0.027127929
1.4323715029
0.3200461354
0.4942912264
1.0663102058
0.5409841906
0.5097090469
-0.3761688634
-1.2294379805
1.059305872
1.255915129
0.9007128153
-0.1886966842
-0.0243503179
-1.2295042902
-1.1690914994
-1.7909222439
-0.1372033815
-1.0397702119
-0.2300666914
0.7292857941
-0.2451420182
-1.4939998222
1.9750850631
2.2478098474
-0.417497362
0.9275358172
0.3855843194
-0.5605985639
0.8462178796
0.0578297284
-1.5405409257
-2.2857519947
1.3649578885
-0.0862266507
0.0708638915
-0.2488795019
-0.1494019622
-1.2016316837
0.6317594718
1.1362290021
-0.6076786254
-1.1195399174
-0.7308139401
-0.7446415692
-0.0723076781
0.4309628478
0.6884036883
1.8160197761
1.7350296559
1.9791702716
-0.0425795625
1.7110745764
-0.5199825406
-0.9218220793
-0.2439408698
-0.2896420157
-0.1352358798
0.5260984115
-0.2201374968
-1.7663791713
-0.4874705382
-0.2367213642
2.0839551687
0.7689220574
2.9756598228
0.383862541
0.1220249645
-2.1967934493
-0.50054396
-2.0393117492
0.6853911984
-0.5329231128
-0.1816943186
-2.1945300726
0.3938599385
0.5773384516
-1.1960596868
-0.7536869216
-1.4591090879
1.6846134724
-0.1795342984
0.0925189102
1.4158998091
0.91085419
-0.7118851097
0.8539552975
1.8368080128
0.7650726264
1.7249008223
0.1513270163
-0.2254166587
-1.4592994508
0.0877399352
0.55897352
-1.7000663914
0.4290057305
-1.6513078443
1.8921216216
2.1431467665
0.9781496517
0.6825667261
-0.7537425765
-1.2981612469
-0.9802443449
1.3898545027
0.5976461446
0.6759937332
1.9627389924
0.7003209808
0.8120493445
0.5893665098
0.3417921283
0.0181794706
-0.0754325438
1.1780289507
0.5148647202
-1.8435082991
0.3320612196
1.2557649009
1.0741365377
1.0396394516
-0.6135630692
0.8362694051
0.6569902288
-1.4073711446
0.9573979777
0.4471649732
-0.4541022365
0.869080958
-0.9699970171
-1.9874102307
-0.7480703403
0.2713083886
-1.6748596563
-1.6575035988
-0.2289141139
-0.9924803578
-0.1009647801
0.0979855113
-0.6153931191
我已将其转换为时间序列对象,如下所示:ts<- ts(time-series, start=c(1979, 1), end=c(2029, 12), frequency=12);
。我正在寻找允许我改变绘图颜色的命令,因为x轴上的特定时间就像我在下面的图片中显示的那样。
我希望自2005年以来,情节会将颜色从蓝色变为红色。
答案 0 :(得分:1)
这是一种方法:
ts<- ts(time-series, start=c(1979, 1), end=c(2029, 12), frequency=12)
plot(window(ts, start=start(ts), end=2000), col="blue", xlim=range(time(ts)), ylim=range(ts))
par(new=TRUE)
plot(window(ts, start=2000), col="red", axes=F, xlab="", ylab="", xlim=range(time(ts)), ylim=range(ts))
可能还有其他更优雅的选择。