@@ -33,6 +33,47 @@ def show_index(arr,index):
33
33
plt .show ()
34
34
plt .close ()
35
35
36
+ #给横坐标由原来的0~480,变成现在的0~24,改变横坐标的比例
37
+ def show_index_ticks (arr ,index ,pic_color ,pic_label ):
38
+ plt .xlabel ("Index of time" )
39
+ plt .ylabel ("Traffic volume" )
40
+ #图例
41
+ plt .plot (arr [index ],color = pic_color ,label = pic_label )
42
+ plt .legend (loc = 'upper right' )
43
+ #改变x轴的刻度
44
+ x_kedu = [0 ,4 ,8 ,12 ,16 ,20 ,24 ]
45
+ orig_ticks = [i * 20 for i in x_kedu ]
46
+ new_ticks = x_kedu
47
+ plt .xticks (orig_ticks ,new_ticks )
48
+ #改变y轴的刻度
49
+ y_kedu = [0 ,5 ,10 ,15 ,20 ]
50
+ y_orig_ticks = y_kedu
51
+ y_new_ticks = y_kedu
52
+ plt .yticks (y_orig_ticks ,y_new_ticks )
53
+ plt .grid ()
54
+ plt .show ()
55
+
56
+
57
+ def show_index_ticks_residual (arr ,index ,pic_color ,pic_label ):
58
+ plt .xlabel ("Time (hour)" )
59
+ plt .ylabel ("Traffic volume" )
60
+ #图例
61
+ plt .plot (arr [index ],color = pic_color ,label = pic_label )
62
+ plt .legend (loc = 'upper right' )
63
+ #改变x轴的刻度
64
+ x_kedu = [0 ,4 ,8 ,12 ,16 ,20 ,24 ]
65
+ orig_ticks = [i * 20 for i in x_kedu ]
66
+ new_ticks = x_kedu
67
+ plt .xticks (orig_ticks ,new_ticks )
68
+ #residual 的 y轴的刻度
69
+ y_kedu = [- 2 ,- 1 ,0 ,1 ,2 ]
70
+ y_orig_ticks = y_kedu
71
+ y_new_ticks = y_kedu
72
+ plt .yticks (y_orig_ticks ,y_new_ticks )
73
+ #加上网格
74
+ plt .grid ()
75
+ plt .show ()
76
+
36
77
if __name__ == "__main__" :
37
78
arr = myload ("dump_arr_9-13.txt" )
38
79
main_x = myload ("dump_main_x_9-13.txt" )
@@ -41,6 +82,10 @@ def show_index(arr,index):
41
82
#show1(main_x)
42
83
#show1(rest_x)
43
84
#show2(main_x,rest_x)
44
- show_index (arr ,0 )
45
- show_index (main_x ,0 )
46
- show_index (rest_x ,0 )
85
+ #show_index(arr,0)
86
+ #show_index(main_x,0)
87
+ #show_index(rest_x,0)
88
+
89
+ show_index_ticks (arr ,3 ,"black" ,"traffic data flow" )
90
+ show_index_ticks (main_x ,3 ,"red" ,"main trend data" )
91
+ show_index_ticks_residual (rest_x ,3 ,"blue" ,"residual data" )
0 commit comments