-
Notifications
You must be signed in to change notification settings - Fork 0
/
lunwen_2_plot.py
1128 lines (939 loc) · 58.7 KB
/
lunwen_2_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
from matplotlib.patches import ConnectionPatch
import matplotlib.ticker as mtick
import matplotlib.gridspec as gridspec
# import matplotlib as mpl
# mpl.rcParams['font.sans-serif'] = ['FangSong']
# mpl.rcParams['axes.unicode_minus']=False
from matplotlib import cm
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
import xlrd
def zhexiantu_fangshan(mappingNumber, enhanceNumber):
'''
绘制折线图
:return:
'''
fig = plt.figure(figsize=(13, 5))
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\fangshan\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\ESN\\test\\ESN_resSize_450.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(mappingNumber,enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS\\test\\LCFBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
# CEBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CEBLS\\test\\CEBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS_ESN\\test\\LCFBLS_ESN_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\GRU\\test\\GRU_fangshan_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LSTM\\test\\LSTM_fangshan_predict.csv"
# GRU_path = 'E:\\yan_1\\BLS_self\\真正意义上的BLS和ESN结合(可以用来实验)\\备份好的BLS和增加增强节点的BLS\\result\\csvFile\\fangshan\\GRU\\GRU_result.csv'
# LSTM_path = 'E:\\yan_1\\BLS_self\\真正意义上的BLS和ESN结合(可以用来实验)\\备份好的BLS和增加增强节点的BLS\\result\\csvFile\\fangshan\\LSTM\\LSTM_result.csv'
startPos = 788
endIndex = 858
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(-1,1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(-1, 1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(-1, 1)
# LCFBLS_data = pd.read_csv(LCFBLS_path).values[startPos:endIndex].reshape(-1, 1)
# CEBLS_data = pd.read_csv(CEBLS_path).values[startPos:endIndex].reshape(-1, 1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
# LCFBLS_ESN_data = pd.read_csv(LCFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(-1, 1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(-1, 1)
color = ['#7030A0', '#00B0F0', '#CD853F', '#00B050', '#92D050', '#FFFF00', '#FFC000', '#9DC3E6', '#8B0000', '#FF0000']
x = np.arange(endIndex-startPos)
plt.plot(x, real_data, color='#d71345', label='real')
plt.plot(x, BLS_data, color='#f47920', label='BLS')
plt.plot(x, ESN_data, color='#b2d235', label='ESN')
plt.plot(x, CFBLS_data, color='#8552a1', label='CMBLS')
# plt.plot(x, BLS_ESN_data, color='#005344', label='BLS_ESN')
plt.plot(x, CFBLS_ESN_data, color='#ef5b9c', label='GRU')
plt.plot(x, GRU_data, color='#009ad6', label='CMBESN')
# plt.plot(x, LSTM_data, color='#ea66a6', label='LSTM')
# plt.title("Mapping node:{} Enhance node:{}".format(mappingNumber,enhanceNumber))
# plt.legend(loc='upper left', bbox_to_anchor=(1, 1)) #把图例设置在外边
plt.legend(loc='lower left', prop={'size': 12}) # 把图例设置在外边
plt.ylabel('AQI', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\第一版修改的图\\ Figure 10.svg', format='svg',
bbox_inches='tight', dpi=600) # 高清图
plt.show()
def plot_ERROR_fangshan(mappingNumber, enhanceNumber):
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\fangshan\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\ESN\\test\\ESN_resSize_450.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS\\test\\LCFBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
# CEBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CEBLS\\test\\CEBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS_ESN\\test\\LCFBLS_ESN_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\GRU\\test\\GRU_fangshan_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LSTM\\test\\LSTM_fangshan_predict.csv"
# GRU_path = 'E:\\yan_1\\BLS_self\\真正意义上的BLS和ESN结合(可以用来实验)\\备份好的BLS和增加增强节点的BLS\\result\\csvFile\\fangshan\\GRU\\GRU_result.csv'
# LSTM_path = 'E:\\yan_1\\BLS_self\\真正意义上的BLS和ESN结合(可以用来实验)\\备份好的BLS和增加增强节点的BLS\\result\\csvFile\\fangshan\\LSTM\\LSTM_result.csv'
startPos = 300
endIndex = 380
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(-1, 1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(-1, 1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(-1, 1)
# LCFBLS_data = pd.read_csv(LCFBLS_path).values[startPos:endIndex].reshape(-1, 1)
# CEBLS_data = pd.read_csv(CEBLS_path).values[startPos:endIndex].reshape(-1, 1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
# LCFBLS_ESN_data = pd.read_csv(LCFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(-1, 1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(-1, 1)
# plt.plot(x, real_data,'-*',color='#ef5b9c',label='real')
# plt.plot(x, BLS_data,'-3', color='#840228', label='BLS')
# plt.plot(x, ESN_data, '-2', color='#1d953f', label='ESN')
# plt.plot(x, CFBLS_data,'-+', color='#87843b', label='CFBLS')
# # plt.plot(x, LCFBLS_data, color='#d71345', label='LCFBLS')
# # plt.plot(x, CEBLS_data, color='#bed742', label='CEBLS')
# plt.plot(x, BLS_ESN_data,'-.', color='#9b95c9', label='BLS_ESN')
# plt.plot(x, CFBLS_ESN_data,'-s', color='#005344', label='CFBLS_ESN')
# # plt.plot(x, LCFBLS_ESN_data, color='#1d953f', label='LCFBLS_ESN')
# plt.plot(x, GRU_data, '-.x',color='#ffc20e', label='GRU')
# plt.plot(x, LSTM_data, '-.1', color='#8552a1', label='LSTM')
# ed1941 b2d235 ba8448 2b4490 5c7a29 009ad6 2585a6 585eaa ea66a6
x1 = np.arange(endIndex - startPos)
ERROR_ESN = []
ERROR_BLS = []
ERROR_CFBLS = []
ERROR_CFBESN = []
ERROR_GRU = []
for i in range(endIndex - startPos):
ERROR_ESN.append(abs(ESN_data[i] - real_data[i]))
ERROR_BLS.append(abs(BLS_data[i] - real_data[i]))
ERROR_CFBLS.append(abs(CFBLS_data[i] - real_data[i]))
ERROR_CFBESN.append(abs(CFBLS_ESN_data[i] - real_data[i]))
ERROR_GRU.append(abs(GRU_data[i] - real_data[i]))
ERROR_ESN = np.array(ERROR_ESN).reshape(-1, 1)
ERROR_BLS = np.array(ERROR_BLS).reshape(-1, 1)
ERROR_CFBLS = np.array(ERROR_CFBLS).reshape(-1, 1)
ERROR_CFBESN = np.array(ERROR_CFBESN).reshape(-1, 1)
ERROR_GRU = np.array(ERROR_GRU).reshape(-1, 1)
gs = gridspec.GridSpec(2, 6) #创建2行6列的网格
lim_xy_max = max(max(ERROR_ESN), max(ERROR_BLS), max(ERROR_CFBLS), max(ERROR_CFBESN), max(ERROR_GRU)) + 0.1
plt.figure(figsize=(12, 6))
plt.subplot(gs[0, :2]) #gs[哪一行,列的范围]
gs.update(hspace=0.3, wspace=0.8)
plt.scatter(x1, ERROR_ESN, s=40, marker='.', c='#00a6ac', label='ESN')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 11})
plt.subplot(gs[0, 2:4]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_BLS, s=40, marker='.', c='#9b95c9', label='BLS')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 11})
plt.subplot(gs[0, 4:6]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_CFBLS, s=40, marker='.', c='#fdb933', label='CMBLS')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 11})
plt.subplot(gs[1, 1:3]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_CFBESN, s=40, marker='.', c='#a3cf62', label='GRU')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 12})
plt.subplot(gs[1, 3:5]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_GRU, s=40, marker='.', c='#f05b72', label='CMBESN')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 12})
# plt.subplots_adjust(hspace=0.3,wspace=0.5) # 调节上下子图之间的行距
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\第一版修改的图\\Figure 12.svg', format='svg',
bbox_inches='tight', dpi=600) # 高清图
plt.show()
def fangshan_boxplot(mappingNumber, enhanceNumber):
'''
这个是把多个箱线图画在一个坐标系中的程序,这里实现的是将所有的预测数据用箱线图来展示出来
:return:
'''
fig = plt.figure(figsize=(13, 5))
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\fangshan\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\ESN\\test\\ESN_resSize_450.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS\\test\\LCFBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
# CEBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CEBLS\\test\\CEBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS_ESN\\test\\LCFBLS_ESN_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\GRU\\test\\GRU_fangshan_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LSTM\\test\\LSTM_fangshan_predict.csv"
startPos = 100
endIndex = 3000
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(1, -1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(1, -1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(1, -1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(1, -1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(1, -1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(1, -1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(1, -1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(1, -1)
SAMPE = {'REAL':real_data[0],'CMBESN':CFBLS_ESN_data[0],'BLS':BLS_data[0],
'ESN':ESN_data[0],'CMBLS':CFBLS_data[0],'GRU':GRU_data[0]}
df = pd.DataFrame(SAMPE)
ff = df.boxplot(showmeans=True, return_type='dict', showfliers=False, vert=True,
sym='o', widths=0.3, whis=True, patch_artist=False, meanline=False,
showcaps=True,flierprops={'markeredgecolor': 'k', 'markersize': 8},
meanprops={'markeredgecolor': 'k', 'markerfacecolor': 'k', 'marker': '*'},figsize=(13, 5))
# color = ['#7030A0', '#00B0F0', '#CD853F', '#00B050', '#92D050', '#FFFF00', '#FFC000', '#9DC3E6', '#8B0000',
# '#FF0000']
# 这里共有5个box
# color = ['#6F933B', '#1B459C', '#16A2FF', '#CE7937', '#FF4025','#7030A0','#9DC3E6'] # 有多少box就对应设置多少颜色
# colors是为了解决上下须不同步,上下帽不同步颜色设置的
colors = ['#6F933B', '#6F933B', '#1B459C', '#1B459C', '#16A2FF', '#16A2FF', '#CE7937',
'#CE7937', '#FF4025', '#FF4025', '#7030A0', '#7030A0', '#9DC3E6', '#9DC3E6']
# ed1941 b2d235 ba8448 2b4490 5c7a29 009ad6 2585a6 585eaa ea66a6
newColor = ['#ef5b9c', '#f47920', '#b2d235', '#817936', '#f15a22', '#009ad6', '#8552a1', '#ffc20e']
newColors = ['#ef5b9c', '#ef5b9c', '#f47920', '#f47920', '#b2d235', '#b2d235', '#817936',
'#817936', '#f15a22', '#f15a22', '#009ad6', '#009ad6', '#8552a1', '#8552a1',
'#ffc20e', '#ffc20e']
# fig = plt.figure(figsize=(13, 5))
linewidth = 1.8
for box, c in zip(ff['boxes'], newColor):
# 箱体边框颜色
box.set(color=c, linewidth=linewidth)
# 箱体内部填充颜色
# box.set(facecolor=c)
# 这里设置的是各个box的其他属性
for whisker, c in zip(ff['whiskers'], newColors):
whisker.set(color=c, linewidth=linewidth)
for cap, c in zip(ff['caps'], newColors):
cap.set(color=c, linewidth=linewidth)
for median, c in zip(ff['medians'], newColor):
median.set(color=c, linewidth=linewidth)
for mean, color in zip(ff['means'], newColor): # 星花是均值
mean.set(markeredgecolor=color, markerfacecolor=color, linewidth=1)
for flier, c in zip(ff['fliers'], newColor):
flier.set(marker='o', color=c, alpha=0.5)
plt.ylabel('AQI')
# plt.savefig('result/SMAPE.png', bbox_inches='tight',dpi=600) # 高清图
# fig.subplots_adjust(right=0.82) # 调整边距和子图的间距
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\CM实验结果图\\CM_箱线图.png', bbox_inches='tight', dpi=600)
plt.show()
def plot_3D_weipinwen_fangshan():
'''
没有使用自平稳优化指标体系的3D绘图
:return:
'''
data_path = r'E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\未使用自平稳指标体系的3D图.xlsx'
data = pd.read_excel(data_path).values[:,:]
# print(data)
X = np.linspace(12,20,5,dtype=int)
Y = np.linspace(20,38,10,dtype=int)
z = np.array(data[:, 3:4]).reshape(10,5)
print(Y)
X, Y = np.meshgrid(X, Y)
fig = plt.figure(figsize=(13, 8))
ax = plt.axes(projection='3d')
# ax.plot_wireframe(X, Y, z, rstride = 1, cstride = 1, cmap='RdPu')
ax.plot_surface(X, Y, z, rstride=1, cstride=1, alpha=0.3,cmap="hsv", linewidth=0, antialiased=False)
ax.contour(X, Y, z, zdir='x', offset=11, cmap="hsv_r")
# ax.contour(X, Y, z, zdir='z', offset=0, cmap="hsv_r")
ax.yaxis.set_major_formatter(mtick.FormatStrFormatter('%d'))
ax.xaxis.set_major_formatter(mtick.FormatStrFormatter('%d'))
ax.set_xlabel('mapping node')
ax.set_ylabel('ESN')
ax.set_zlabel('RMSE', rotation=90)
# ax.grid(False, linestyle = "-.", color = "red", linewidth = "1")
ax.view_init(elev=19, azim=35)
# ax.contour(X, Y, z, cmap=cm.coolwarm)
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\未使用自平稳指标体系的3D图.png', bbox_inches='tight', dpi=600)
# 调整观察角度和方位角。这里将俯仰角设为60度,把方位角调整为35度
plt.show()
def plot_3D_pinwen_fangshan():
'''
没有使用自平稳优化指标体系的3D绘图
:return:
'''
data_path = r'E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\自平稳指标体系的3D图.xlsx'
data = pd.read_excel(data_path).values[:,:]
# print(data)
X = np.linspace(12,28,9,dtype=int)
Y = np.linspace(20,38,10,dtype=int)
z = np.array(data[:, 3:4]).reshape(10,9)
'''
cmap = "以下的取值"
'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges',
'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu',
'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r',
'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3',
'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd',
'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r',
'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag',
'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r',
'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r',
'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r',
'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow',
'rainbow_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b',
'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted',
'twilight_shifted_r', 'viridis', 'viridis_r', 'winter', 'winter_r'
'''
X, Y = np.meshgrid(X, Y)
fig = plt.figure(figsize=(13, 8))
ax = plt.axes(projection='3d')
# ax.plot_wireframe(X, Y, z, rstride = 1, cstride = 1, cmap='RdPu')
ax.plot_surface(X, Y, z, rstride=2, cstride=2, alpha=0.45,cmap="Paired", linewidth=0, antialiased=False)
ax.contour(X, Y, z, zdir='x', offset=11, cmap="Paired")
# ax.contour(X, Y, z, zdir='y', offset=20, cmap="Paired")
ax.yaxis.set_major_formatter(mtick.FormatStrFormatter('%d'))
ax.xaxis.set_major_formatter(mtick.FormatStrFormatter('%d'))
ax.set_xlabel('mapping node')
ax.set_ylabel('ESN')
ax.set_zlabel('RMSE', rotation=90)
# ax.grid(False, linestyle = "-.", color = "red", linewidth = "1")
ax.view_init(elev=17, azim=42)
# ax.contour(X, Y, z, cmap=cm.coolwarm)
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\使用自平稳指标体系的3D图.png', bbox_inches='tight', dpi=600)
# 调整观察角度和方位角。这里将俯仰角设为60度,把方位角调整为35度
plt.show()
def getStationaryFigure():
#得到自平稳指标体系RMSE曲线图
StationaryPath = "E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\自平稳指标体系实验数据.xlsx"
StationaryData = pd.read_excel(r'E:\\yan_2\\12_5论文\\实验结果图\\fangshan\\自平稳指标体系实验数据.xlsx').values[1:].reshape(-1,1)
fig = plt.figure(figsize=(13, 5))
x = np.arange(len(StationaryData))
plt.plot(x, StationaryData, 'c-*',color='#1B459C')
plt.show()
def zhexiantu_MSO_8(mappingNumber, enhanceNumber):
'''
绘制折线图
:return:
'''
fig = plt.figure(figsize=(13, 5))
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\MSO_8\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\ESN\\test\\ESN_resSize_920.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(mappingNumber,enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS\\test\\LCFBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
# CEBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CEBLS\\test\\CEBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS_ESN\\test\\LCFBLS_ESN_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\GRU\\test\\GRU_MSO_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\LSTM\\test\\LSTM_MSO_predict.csv"
startPos = 1000
endIndex = 1601
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(-1,1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(-1, 1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(-1, 1)
# LCFBLS_data = pd.read_csv(LCFBLS_path).values[startPos:endIndex].reshape(-1, 1)
# CEBLS_data = pd.read_csv(CEBLS_path).values[startPos:endIndex].reshape(-1, 1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
# LCFBLS_ESN_data = pd.read_csv(LCFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(-1, 1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(-1, 1)
color = ['#7030A0', '#00B0F0', '#CD853F', '#00B050', '#92D050', '#FFFF00', '#FFC000', '#9DC3E6', '#8B0000', '#FF0000']
x = np.arange(endIndex-startPos)
plt.plot(x, real_data,color='#ef5b9c',label='real')
plt.plot(x, BLS_data, color='#840228', label='BLS')
plt.plot(x, ESN_data, color='#1d953f', label='ESN')
plt.plot(x, CFBLS_data, color='#87843b', label='CFBLS')
# plt.plot(x, BLS_ESN_data, color='#9b95c9', label='BLS_ESN')
plt.plot(x, CFBLS_ESN_data, color='#005344', label='CFBLS_ESN')
plt.plot(x, GRU_data, color='#ffc20e', label='GRU')
# plt.plot(x, LSTM_data, color='#8552a1', label='LSTM')
#ed1941 b2d235 ba8448 2b4490 5c7a29 009ad6 2585a6 585eaa ea66a6
# plt.title("Mapping node:{} Enhance node:{}".format(mappingNumber,enhanceNumber))
plt.legend(loc='upper left', bbox_to_anchor=(1, 1)) #把图例设置在外边
plt.ylabel('AQI')
fig.subplots_adjust(right=0.90) #调整边距和子图的间距
# plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\折线图.png', bbox_inches='tight', dpi=600) # 高清图
plt.show()
def MSO_8_boxplot(mappingNumber, enhanceNumber):
'''
这个是把多个箱线图画在一个坐标系中的程序,这里实现的是将所有的预测数据用箱线图来展示出来
:return:
'''
fig = plt.figure(figsize=(13, 5))
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\MSO_8\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\ESN\\test\\ESN_resSize_920.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS\\test\\LCFBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
# CEBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\CEBLS\\test\\CEBLS_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
# LCFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\fangshan\\LCFBLS_ESN\\test\\LCFBLS_ESN_mapping_{}_enhance_{}.csv".format(
# mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\GRU\\test\\GRU_MSO_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\LSTM\\test\\LSTM_MSO_predict.csv"
startPos = 100
endIndex = 3000
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(1, -1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(1, -1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(1, -1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(1, -1)
# LCFBLS_data = pd.read_csv(LCFBLS_path).values[startPos:endIndex].reshape(1, -1)
# CEBLS_data = pd.read_csv(CEBLS_path).values[startPos:endIndex].reshape(1, -1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(1, -1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(1, -1)
# LCFBLS_ESN_data = pd.read_csv(LCFBLS_ESN_path).values[startPos:endIndex].reshape(1, -1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(1, -1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(1, -1)
SAMPE = {'REAL':real_data[0],'CFBESN':CFBLS_ESN_data[0],'BESN':BLS_ESN_data[0],'BLS':BLS_data[0],
'ESN':ESN_data[0],'CFBLS':CFBLS_data[0],'GRU':GRU_data[0],'LSTM':LSTM_data[0]}
df = pd.DataFrame(SAMPE)
ff = df.boxplot(showmeans=True, return_type='dict', showfliers=False, vert=True,
sym='o', widths=0.3, whis=True, patch_artist=False, meanline=False,
showcaps=True,flierprops={'markeredgecolor': 'k', 'markersize': 8},
meanprops={'markeredgecolor': 'k', 'markerfacecolor': 'k', 'marker': '*'},figsize=(13, 5))
# color = ['#7030A0', '#00B0F0', '#CD853F', '#00B050', '#92D050', '#FFFF00', '#FFC000', '#9DC3E6', '#8B0000',
# '#FF0000']
# 这里共有5个box
# color = ['#6F933B', '#1B459C', '#16A2FF', '#CE7937', '#FF4025','#7030A0','#9DC3E6'] # 有多少box就对应设置多少颜色
# colors是为了解决上下须不同步,上下帽不同步颜色设置的
colors = ['#6F933B', '#6F933B', '#1B459C', '#1B459C', '#16A2FF', '#16A2FF', '#CE7937',
'#CE7937', '#FF4025', '#FF4025', '#7030A0', '#7030A0', '#9DC3E6', '#9DC3E6']
# ed1941 b2d235 ba8448 2b4490 5c7a29 009ad6 2585a6 585eaa ea66a6
newColor = ['#ed1941', '#b2d235', '#ba8448', '#2b4490', '#5c7a29', '#009ad6', '#2585a6','#585eaa','#ea66a6']
newColors = ['#ed1941', '#ed1941', '#b2d235', '#b2d235', '#ba8448', '#ba8448', '#2b4490',
'#2b4490', '#5c7a29', '#5c7a29', '#009ad6', '#009ad6', '#2585a6', '#2585a6',
'#585eaa', '#585eaa', '#ea66a6', '#ea66a6']
# fig = plt.figure(figsize=(13, 5))
linewidth = 1.8
for box, c in zip(ff['boxes'], newColor):
# 箱体边框颜色
box.set(color=c, linewidth=linewidth)
# 箱体内部填充颜色
# box.set(facecolor=c)
# 这里设置的是各个box的其他属性
for whisker, c in zip(ff['whiskers'], newColors):
whisker.set(color=c, linewidth=linewidth)
for cap, c in zip(ff['caps'], newColors):
cap.set(color=c, linewidth=linewidth)
for median, c in zip(ff['medians'], newColor):
median.set(color=c, linewidth=linewidth)
for mean, color in zip(ff['means'], newColor): # 星花是均值
mean.set(markeredgecolor=color, markerfacecolor=color, linewidth=1)
for flier, c in zip(ff['fliers'], newColor):
flier.set(marker='o', color=c, alpha=0.5)
plt.ylabel('AQI')
# plt.savefig('result/SMAPE.png', bbox_inches='tight',dpi=600) # 高清图
# fig.subplots_adjust(right=0.82) # 调整边距和子图的间距
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\箱线图.png', bbox_inches='tight', dpi=600)
plt.show()
def jubufangda_MSO_8(mappingNumber, enhanceNumber):
startPos = 270
endIndex = 321
MAX_EPISODES = endIndex - startPos
x_axis_data = []
for l in range(MAX_EPISODES):
x_axis_data.append(l)
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\MSO_8\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\ESN\\test\\ESN_resSize_920.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\GRU\\test\\GRU_MSO_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\LSTM\\test\\LSTM_MSO_predict.csv"
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(-1, 1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(-1, 1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(-1, 1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(-1, 1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(-1, 1)
fig, ax = plt.subplots(1, 1, figsize=(12, 5))
# plt.plot(x_axis_data, real_data, '-.1', color='#ef5b9c', label='real')
# plt.plot(x_axis_data, BLS_data, '-.2', color='#f47920', label='BLS')
# plt.plot(x_axis_data, ESN_data, '-.3', color='#b2d235', label='ESN')
# plt.plot(x_axis_data, CFBLS_data, '-.4', color='#817936', label='CMBLS')
# # plt.plot(x_axis_data, BLS_ESN_data, '-.>', color='#f15a22', label='BLS_ESN')
# plt.plot(x_axis_data, CFBLS_ESN_data, '-.+', color='#009ad6', label='CMBESN')
# plt.plot(x_axis_data, GRU_data, '-.*', color='#8552a1', label='GRU')
# # plt.plot(x_axis_data, LSTM_data, '-.|', color='#ffc20e', label='LSTM')
plt.plot(x_axis_data, real_data, color='#ef5b9c', label='real')
plt.plot(x_axis_data, BLS_data, color='#f47920', label='BLS')
plt.plot(x_axis_data, ESN_data, color='#b2d235', label='ESN')
plt.plot(x_axis_data, CFBLS_data, color='#817936', label='CMBLS')
# plt.plot(x_axis_data, BLS_ESN_data, '-.>', color='#f15a22', label='BLS_ESN')
plt.plot(x_axis_data, CFBLS_ESN_data, color='#009ad6', label='CMBESN')
plt.plot(x_axis_data, GRU_data, color='#8552a1', label='GRU')
# plt.plot(x_axis_data, LSTM_data, '-.|', color='#ffc20e', label='LSTM')
plt.ylabel('MSO Value', fontsize = 14)
plt.xlabel('Observed Point', fontsize = 14)
# plt.legend(loc='upper left', bbox_to_anchor=(1, 1)) # 把图例设置在外边
plt.legend(loc='upper left', prop={'size' : 14}) # 把图例设置在外边
# plt.ylabel('Death number')
# 嵌入局部放大图的坐标系
axins = inset_axes(ax, width="40%", height="30%", loc='lower left',
bbox_to_anchor=(0.52, 0.62, 0.8, 1.2),
bbox_transform=ax.transAxes)
# 在子坐标系中绘制原始数据
axins.plot(x_axis_data, real_data, color='#ef5b9c', alpha=0.8, linewidth=1.5)
axins.plot(x_axis_data, BLS_data, color='#f47920', alpha=0.8, linewidth=1.5)
axins.plot(x_axis_data, ESN_data, color='#b2d235', alpha=0.8, linewidth=1.5)
axins.plot(x_axis_data, CFBLS_data, color='#817936', alpha=0.8, linewidth=1.5)
axins.plot(x_axis_data, BLS_ESN_data, color='#f15a22', alpha=0.8, linewidth=1.5)
axins.plot(x_axis_data, CFBLS_ESN_data, color='#009ad6', alpha=0.8, linewidth=1.5)
plt.plot(x_axis_data, GRU_data, color='#8552a1', alpha=0.8, linewidth=1.5)
plt.plot(x_axis_data, LSTM_data, color='#ffc20e', alpha=0.8, linewidth=1.5)
# 设置放大区间,调整子坐标系的显示范围
# 设置放大区间
zone_left = 25
zone_right = 29
# 坐标轴的扩展比例(根据实际数据调整)
x_ratio = 0.0 # x轴显示范围的扩展比例
y_ratio = 0.07 # y轴显示范围的扩展比例
# X轴的显示范围
xlim0 = x_axis_data[zone_left] - (x_axis_data[zone_right] - x_axis_data[zone_left]) * x_ratio
xlim1 = x_axis_data[zone_right] + (x_axis_data[zone_right] - x_axis_data[zone_left]) * x_ratio
# Y轴的显示范围
y = np.hstack((real_data[zone_left:zone_right], BLS_data[zone_left:zone_right],
ESN_data[zone_left:zone_right], CFBLS_data[zone_left:zone_right],
CFBLS_ESN_data[zone_left:zone_right],GRU_data[zone_left:zone_right]))
ylim0 = np.min(y) - (np.max(y) - np.min(y)) * y_ratio
ylim1 = np.max(y) + (np.max(y) - np.min(y)) * y_ratio
# 调整子坐标系的显示范围
axins.set_xlim(xlim0, xlim1)
axins.set_ylim(ylim0, ylim1)
# 建立父坐标系与子坐标系的连接线
# 原图中画方框
tx0 = xlim0
tx1 = xlim1
ty0 = ylim0
ty1 = ylim1
sx = [tx0, tx1, tx1, tx0, tx0]
sy = [ty0, ty0, ty1, ty1, ty0]
ax.plot(sx, sy, "#CD853F")
print('xlim0 : ', xlim0)
print('xlim1 : ', xlim1)
print('ylim0 : ', ylim0)
print('ylim1 : ', ylim1)
# 画两条线
xy = (xlim0, ylim1) # (60,-409)
xy2 = (xlim0, ylim0) # (60,409)
con = ConnectionPatch(xyA=xy2, xyB=xy, coordsA="data", coordsB="data",
axesA=axins, axesB=ax, color='#b22c46')
axins.add_artist(con)
xy = (xlim1, ylim1) # (90,-409)
xy2 = (xlim1, ylim0) # (90,-409)
con = ConnectionPatch(xyA=xy2, xyB=xy, coordsA="data", coordsB="data",
axesA=axins, axesB=ax, color='#b22c46')
axins.add_artist(con)
# plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\第一版修改的图\\CM_局部放大图_折线图.svg', format='svg', bbox_inches='tight', dpi=800) # 高清图
# plt.show()
x1 = np.arange(endIndex-startPos)
fig1, vax = plt.subplots(1, 1, figsize=(11, 5))
ERROR_ESN = []
ERROR_BLS = []
ERROR_CFBLS = []
ERROR_CFBESN = []
ERROR_GRU = []
for i in range(endIndex-startPos):
ERROR_ESN.append(abs(ESN_data[i] - real_data[i]))
ERROR_BLS.append(abs(BLS_data[i] - real_data[i]))
ERROR_CFBLS.append(abs(CFBLS_data[i] - real_data[i]))
ERROR_CFBESN.append(abs(CFBLS_ESN_data[i] - real_data[i]))
ERROR_GRU.append(abs(GRU_data[i] - real_data[i]))
ERROR_ESN = np.array(ERROR_ESN).reshape(-1, 1)
ERROR_BLS = np.array(ERROR_BLS).reshape(-1, 1)
ERROR_CFBLS = np.array(ERROR_CFBLS).reshape(-1, 1)
ERROR_CFBESN = np.array(ERROR_CFBESN).reshape(-1, 1)
ERROR_GRU = np.array(ERROR_GRU).reshape(-1, 1)
# plt.vlines(x1, [0], ERROR_ESN, colors='#00a6ac', label='ESN')
# plt.vlines(x1, [0], ERROR_BLS, colors='#9b95c9', label='BLS')
# plt.vlines(x1, [0], ERROR_CFBLS, colors='#fdb933', label='CMBLS')
# plt.vlines(x1, [0], ERROR_CFBESN, colors='#a3cf62', label='GRU')
# plt.vlines(x1, [0], ERROR_GRU, colors='#f05b72', label='CMBESN')
# plt.plot(x, ERROR_ESN, color='#b2d235', label='ESN')
# plt.plot(x, ERROR_BLS, color='#f47920', label='BLS')
# plt.plot(x, ERROR_CFBLS, color='#817936', label='CFESN')
# plt.plot(x, ERROR_CFBESN, color='#8552a1', label='CFBESN')
# plt.plot(x, ERROR_GRU, color='#009ad6', label='GRU')
plt.scatter(x1, ERROR_ESN, s=18, marker='.', c='#00a6ac', label='ESN')
plt.scatter(x1, ERROR_BLS, s=18, marker='o', c='#9b95c9', label='BLS')
plt.scatter(x1, ERROR_CFBLS, s=18, marker='v', c='#fdb933', label='CMBLS')
plt.scatter(x1, ERROR_CFBESN, s=18, marker='p', c='#a3cf62', label='GRU')
plt.scatter(x1, ERROR_GRU, s=18, marker='D', c='#f05b72', label='CMBESN')
plt.ylabel('Errors', fontsize = 14)
plt.xlabel('Time steps', fontsize = 14)
# fig1.subplots_adjust(right=0.88) # 调整边距和子图的间距
# plt.legend(loc='lower left') # 把图例设置在外边
# plt.legend(loc='upper left', bbox_to_anchor=(0.995, 1)) # 把图例设置在外边
plt.legend(loc='upper right', prop={'size': 13}) # 把图例设置在外边
# fig.subplots_adjust(right=1.5) # 调整边距和子图的间距
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\第一版修改的图\\CM_所有模型_误差垂线图_补审稿人1_加绝对值.svg', format='svg',bbox_inches='tight', dpi=600) # 高清图
plt.show()
def plot_ERROR_MSO_8(mappingNumber, enhanceNumber):
'''
将所有模型的误差绘制在同一张图上
startPos = 270
endIndex = 321
fig = plt.figure(figsize=(12, 5))
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\MSO_8\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\ESN\\test\\ESN_resSize_920.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\GRU\\test\\GRU_MSO_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\LSTM\\test\\LSTM_MSO_predict.csv"
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(-1, 1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(-1, 1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(-1, 1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(-1, 1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(-1, 1)
x1 = np.arange(endIndex - startPos)
ERROR_ESN = []
ERROR_BLS = []
ERROR_CFBLS = []
ERROR_CFBESN = []
ERROR_GRU = []
for i in range(endIndex - startPos):
ERROR_ESN.append(abs(ESN_data[i] - real_data[i]))
ERROR_BLS.append(abs(BLS_data[i] - real_data[i]))
ERROR_CFBLS.append(abs(CFBLS_data[i] - real_data[i]))
ERROR_CFBESN.append(abs(CFBLS_ESN_data[i] - real_data[i]))
ERROR_GRU.append(abs(GRU_data[i] - real_data[i]))
ERROR_ESN = np.array(ERROR_ESN).reshape(-1, 1)
ERROR_BLS = np.array(ERROR_BLS).reshape(-1, 1)
ERROR_CFBLS = np.array(ERROR_CFBLS).reshape(-1, 1)
ERROR_CFBESN = np.array(ERROR_CFBESN).reshape(-1, 1)
ERROR_GRU = np.array(ERROR_GRU).reshape(-1, 1)
# plt.vlines(x1, [0], ERROR_ESN, colors='#00a6ac', label='ESN')
# plt.vlines(x1, [0], ERROR_BLS, colors='#9b95c9', label='BLS')
# plt.vlines(x1, [0], ERROR_CFBLS, colors='#fdb933', label='CMBLS')
# plt.vlines(x1, [0], ERROR_CFBESN, colors='#a3cf62', label='GRU')
# plt.vlines(x1, [0], ERROR_GRU, colors='#f05b72', label='CMBESN')
# plt.plot(x, ERROR_ESN, color='#b2d235', label='ESN')
# plt.plot(x, ERROR_BLS, color='#f47920', label='BLS')
# plt.plot(x, ERROR_CFBLS, color='#817936', label='CFESN')
# plt.plot(x, ERROR_CFBESN, color='#8552a1', label='CFBESN')
# plt.plot(x, ERROR_GRU, color='#009ad6', label='GRU')
plt.scatter(x1, ERROR_ESN, s=18, marker='.', c='#00a6ac', label='ESN')
plt.scatter(x1, ERROR_BLS, s=18, marker='o', c='#9b95c9', label='BLS')
plt.scatter(x1, ERROR_CFBLS, s=18, marker='v', c='#fdb933', label='CMBLS')
plt.scatter(x1, ERROR_CFBESN, s=18, marker='p', c='#a3cf62', label='GRU')
plt.scatter(x1, ERROR_GRU, s=18, marker='D', c='#f05b72', label='CMBESN')
plt.ylabel('Errors', fontsize=14)
plt.xlabel('Time steps', fontsize=14)
# fig1.subplots_adjust(right=0.88) # 调整边距和子图的间距
# plt.legend(loc='lower left') # 把图例设置在外边
# plt.legend(loc='upper left', bbox_to_anchor=(0.995, 1)) # 把图例设置在外边
plt.legend(loc='upper right', prop={'size': 13}) # 把图例设置在外边
# fig.subplots_adjust(right=1.5) # 调整边距和子图的间距
# plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\第一版修改的图\\CM_所有模型_误差垂线图_补审稿人1_加绝对值.svg', format='svg',
# bbox_inches='tight', dpi=600) # 高清图
plt.show()
'''
startPos = 350
endIndex = 400
real_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\realData\\MSO_8\\test\\testReal.csv'
ESN_path = 'E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\ESN\\test\\ESN_resSize_920.csv'
BLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS\\test\\BLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS\\test\\CFBLS_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
BLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\BLS_ESN\\test\\BLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
CFBLS_ESN_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\CFBLS_ESN\\test\\CFBLS_ESN_mapping_{}_enhance_{}.csv".format(
mappingNumber, enhanceNumber)
GRU_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\GRU\\test\\GRU_MSO_predict.csv"
LSTM_path = "E:\\yan_2\\CFBLS_LCFBLS复现\\result\\csvFile\\MSO_8\\LSTM\\test\\LSTM_MSO_predict.csv"
real_data = pd.read_csv(real_path).values[startPos:endIndex].reshape(-1, 1)
ESN_data = pd.read_csv(ESN_path).values[startPos:endIndex].reshape(-1, 1)
BLS_data = pd.read_csv(BLS_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_data = pd.read_csv(CFBLS_path).values[startPos:endIndex].reshape(-1, 1)
BLS_ESN_data = pd.read_csv(BLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
CFBLS_ESN_data = pd.read_csv(CFBLS_ESN_path).values[startPos:endIndex].reshape(-1, 1)
GRU_data = pd.read_csv(GRU_path).values[startPos:endIndex].reshape(-1, 1)
LSTM_data = pd.read_csv(LSTM_path).values[startPos:endIndex].reshape(-1, 1)
x1 = np.arange(endIndex - startPos)
ERROR_ESN = []
ERROR_BLS = []
ERROR_CFBLS = []
ERROR_CFBESN = []
ERROR_GRU = []
for i in range(endIndex - startPos):
ERROR_ESN.append(abs(ESN_data[i] - real_data[i]))
ERROR_BLS.append(abs(BLS_data[i] - real_data[i]))
ERROR_CFBLS.append(abs(CFBLS_data[i] - real_data[i]))
ERROR_CFBESN.append(abs(CFBLS_ESN_data[i] - real_data[i]))
ERROR_GRU.append(abs(GRU_data[i] - real_data[i]))
ERROR_ESN = np.array(ERROR_ESN).reshape(-1, 1)
ERROR_BLS = np.array(ERROR_BLS).reshape(-1, 1)
ERROR_CFBLS = np.array(ERROR_CFBLS).reshape(-1, 1)
ERROR_CFBESN = np.array(ERROR_CFBESN).reshape(-1, 1)
ERROR_GRU = np.array(ERROR_GRU).reshape(-1, 1)
gs = gridspec.GridSpec(2, 6) #创建2行6列的网格
lim_xy_max = max(max(ERROR_ESN), max(ERROR_BLS), max(ERROR_CFBLS), max(ERROR_CFBESN), max(ERROR_GRU)) + 0.1
plt.figure(figsize=(12, 6))
plt.subplot(gs[0, :2]) #gs[哪一行,列的范围]
gs.update(hspace=0.3, wspace=0.8)
plt.scatter(x1, ERROR_ESN, s=40, marker='.', c='#00a6ac', label='ESN')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 11})
plt.subplot(gs[0, 2:4]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_BLS, s=40, marker='.', c='#9b95c9', label='BLS')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 11})
plt.subplot(gs[0, 4:6]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_CFBLS, s=40, marker='.', c='#fdb933', label='CMBLS')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 11})
plt.subplot(gs[1, 1:3]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_CFBESN, s=40, marker='.', c='#a3cf62', label='GRU')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 12})
plt.subplot(gs[1, 3:5]) #gs[哪一行,列的范围]
plt.scatter(x1, ERROR_GRU, s=40, marker='.', c='#f05b72', label='CMBESN')
plt.ylim(0, lim_xy_max)
plt.ylabel('Errors', fontsize=13)
plt.xlabel('Time steps', fontsize=13)
plt.legend(loc='upper right', prop={'size': 12})
# plt.subplots_adjust(hspace=0.3,wspace=0.5) # 调节上下子图之间的行距
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\第一版修改的图\\CM_所有模型_误差垂线图_补审稿人1_加绝对值.svg', format='svg',
bbox_inches='tight', dpi=600) # 高清图
plt.show()
def plot_3D_weipinwen_MSO_8():
'''
没有使用自平稳优化指标体系的3D绘图
:return:
'''
data_path = r'E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\未使用自平稳指标体系的3D图.xlsx'
data = pd.read_excel(data_path).values[:,:]
# print(data)
X = np.linspace(14,22,5)
Y = np.linspace(2,28,14)
z = np.array(data[:,3:4]).reshape(14,5)
# print("x:",x)
# print("y:", y)
# print("z:", z)
'''
cmap = "以下的取值"
'CMRmap_r', 'Dark2', 'Dark2_r', 'GnBu', 'GnBu_r', 'Greens', 'Greens_r', 'Greys', 'Greys_r', 'OrRd', 'OrRd_r', 'Oranges',
'Oranges_r', 'PRGn', 'PRGn_r', 'Paired', 'Paired_r', 'Pastel1', 'Pastel1_r', 'Pastel2', 'Pastel2_r', 'PiYG', 'PiYG_r', 'PuBu',
'PuBuGn', 'PuBuGn_r', 'PuBu_r', 'PuOr', 'PuOr_r', 'PuRd', 'PuRd_r', 'Purples', 'Purples_r', 'RdBu', 'RdBu_r', 'RdGy', 'RdGy_r',
'RdPu', 'RdPu_r', 'RdYlBu', 'RdYlBu_r', 'RdYlGn', 'RdYlGn_r', 'Reds', 'Reds_r', 'Set1', 'Set1_r', 'Set2', 'Set2_r', 'Set3',
'Set3_r', 'Spectral', 'Spectral_r', 'Wistia', 'Wistia_r', 'YlGn', 'YlGnBu', 'YlGnBu_r', 'YlGn_r', 'YlOrBr', 'YlOrBr_r', 'YlOrRd',
'YlOrRd_r', 'afmhot', 'afmhot_r', 'autumn', 'autumn_r', 'binary', 'binary_r', 'bone', 'bone_r', 'brg', 'brg_r', 'bwr', 'bwr_r',
'cividis', 'cividis_r', 'cool', 'cool_r', 'coolwarm', 'coolwarm_r', 'copper', 'copper_r', 'cubehelix', 'cubehelix_r', 'flag',
'flag_r', 'gist_earth', 'gist_earth_r', 'gist_gray', 'gist_gray_r', 'gist_heat', 'gist_heat_r', 'gist_ncar', 'gist_ncar_r',
'gist_rainbow', 'gist_rainbow_r', 'gist_stern', 'gist_stern_r', 'gist_yarg', 'gist_yarg_r', 'gnuplot', 'gnuplot2', 'gnuplot2_r',
'gnuplot_r', 'gray', 'gray_r', 'hot', 'hot_r', 'hsv', 'hsv_r', 'inferno', 'inferno_r', 'jet', 'jet_r', 'magma', 'magma_r',
'nipy_spectral', 'nipy_spectral_r', 'ocean', 'ocean_r', 'pink', 'pink_r', 'plasma', 'plasma_r', 'prism', 'prism_r', 'rainbow',
'rainbow_r', 'seismic', 'seismic_r', 'spring', 'spring_r', 'summer', 'summer_r', 'tab10', 'tab10_r', 'tab20', 'tab20_r', 'tab20b',
'tab20b_r', 'tab20c', 'tab20c_r', 'terrain', 'terrain_r', 'turbo', 'turbo_r', 'twilight', 'twilight_r', 'twilight_shifted',
'twilight_shifted_r', 'viridis', 'viridis_r', 'winter', 'winter_r'
'''
X, Y = np.meshgrid(X, Y)
fig = plt.figure(figsize=(13, 8))
ax = plt.axes(projection='3d')
# ax.plot_wireframe(X, Y, z, rstride = 1, cstride = 1, cmap='RdPu')
ax.plot_surface(X, Y, z, rstride=1, cstride=1, alpha=0.3,cmap="hsv_r", linewidth=0, antialiased=False)
ax.contour(X, Y, z, zdir='x', offset=13, cmap="hsv_r")
# ax.contour(X, Y, z, zdir='y', offset=30, cmap=cm.coolwarm)
ax.set_xlabel('mapping node')
ax.set_ylabel('ESN')
ax.set_zlabel('RMSE', rotation=90)
# ax.grid(False, linestyle = "-.", color = "red", linewidth = "1")
ax.view_init(elev=18, azim=45)
# ax.contour(X, Y, z, cmap=cm.coolwarm)
plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\未使用自平稳指标体系的3D图.png', bbox_inches='tight', dpi=600)
# 调整观察角度和方位角。这里将俯仰角设为60度,把方位角调整为35度
plt.show()
def plot_3D_pinwen_MSO_8():
'''
没有使用自平稳优化指标体系的3D绘图
:return:
'''
data_path = r'E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\自平稳指标体系的3D图.xlsx'
data = pd.read_excel(data_path).values[:,:]
# print(data)
X = np.linspace(14,36,12)
Y = np.linspace(2,28,14)
z = np.array(data[:,3:4]).reshape(14,12)
X, Y = np.meshgrid(X, Y)
fig = plt.figure(figsize=(13, 8))
ax = plt.axes(projection='3d')
# ax.plot_wireframe(X, Y, z, rstride = 1, cstride = 1, cmap='RdPu')
ax.plot_surface(X, Y, z, rstride=2, cstride=2, alpha=0.3,cmap="hsv", linewidth=0, antialiased=False)
ax.contour(X, Y, z, zdir='x', offset=13, cmap="hsv_r")
# ax.contour(X, Y, z, zdir='z', offset=0, cmap="hsv_r")
ax.set_xlabel('mapping node')
ax.set_ylabel('ESN')
ax.set_zlabel('RMSE', rotation=90)
# ax.grid(False, linestyle = "-.", color = "red", linewidth = "1")
ax.view_init(elev=11, azim=49)
# ax.contour(X, Y, z, cmap=cm.coolwarm)
# plt.savefig('E:\\yan_2\\12_5论文\\实验结果图\\MSO_8\\使用自平稳指标体系的3D图.png', bbox_inches='tight', dpi=600)
# 调整观察角度和方位角。这里将俯仰角设为60度,把方位角调整为35度
plt.show()
def plot_real_data_fangshan():
path = 'E:\\yan_1\\BLS_self\\fangshan.csv'
AQI = pd.read_csv(path).values[1000:2000, :1].reshape(-1, 1)
# AQI = pd.read_csv(path).values[1000:15000, :1].reshape(-1, 1)
x = np.arange(AQI.shape[0])
plt.figure(figsize=(13, 6))