siat 3.6.1__py3-none-any.whl → 3.6.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- siat/capm_beta2.py +40 -43
- siat/grafix.py +249 -26
- siat/risk_adjusted_return2.py +79 -88
- siat/security_trend2.py +21 -21
- siat/stock.py +41 -48
- siat/valuation.py +14 -15
- {siat-3.6.1.dist-info → siat-3.6.6.dist-info}/METADATA +1 -1
- {siat-3.6.1.dist-info → siat-3.6.6.dist-info}/RECORD +11 -11
- {siat-3.6.1.dist-info → siat-3.6.6.dist-info}/LICENSE +0 -0
- {siat-3.6.1.dist-info → siat-3.6.6.dist-info}/WHEEL +0 -0
- {siat-3.6.1.dist-info → siat-3.6.6.dist-info}/top_level.txt +0 -0
siat/grafix.py
CHANGED
@@ -117,9 +117,8 @@ if __name__ =="__main__":
|
|
117
117
|
|
118
118
|
def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
119
119
|
power=0,zeroline=False, \
|
120
|
-
attention_value='', \
|
121
|
-
attention_point='', \
|
122
|
-
|
120
|
+
attention_value='',attention_value_area='', \
|
121
|
+
attention_point='',attention_point_area='', \
|
123
122
|
average_value=False, \
|
124
123
|
|
125
124
|
resample_freq='H',loc='best', \
|
@@ -265,7 +264,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
|
265
264
|
#用于关注值的颜色列表
|
266
265
|
atv_color_list=["lightgray","paleturquoise","wheat","khaki","lightsage"]
|
267
266
|
#用于关注点的颜色列表
|
268
|
-
atp_color_list=["
|
267
|
+
atp_color_list=["crimson","dodgerblue","magenta","lightseagreen","chocolate"]
|
269
268
|
|
270
269
|
if not attention_value=='':
|
271
270
|
if isinstance(attention_value,int) or isinstance(attention_value,float):
|
@@ -280,6 +279,11 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
|
280
279
|
color=atv_color_list[pos]
|
281
280
|
plt.axhline(y=at,ls=":",c=color,linewidth=2,label=text_lang("关注值","Attention value ")+str(at))
|
282
281
|
|
282
|
+
if not attention_value_area=='':
|
283
|
+
if isinstance(attention_value_area,list) and len(attention_value_area)>=2:
|
284
|
+
plt.fill_between(df.index,attention_value_area[0],attention_value_area[1],color='lightgray',alpha=0.5)
|
285
|
+
|
286
|
+
import pandas as pd
|
283
287
|
if not attention_point=='':
|
284
288
|
if isinstance(attention_point,str) or isinstance(attention_point,int) or isinstance(attention_point,float):
|
285
289
|
atp_list=[attention_point]
|
@@ -288,7 +292,7 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
|
288
292
|
else:
|
289
293
|
atp_list=[]
|
290
294
|
if not atp_list==[] and not atp_list==['']:
|
291
|
-
|
295
|
+
|
292
296
|
for at in atp_list:
|
293
297
|
pos=atp_list.index(at)
|
294
298
|
color=atp_color_list[pos]
|
@@ -300,6 +304,19 @@ def plot_line(df0,colname,collabel,ylabeltxt,titletxt,footnote,datatag=False, \
|
|
300
304
|
atpd=at
|
301
305
|
plt.axvline(x=atpd,ls=":",c=color,linewidth=1.5,label=text_lang("关注点","Attention point ")+str(at))
|
302
306
|
|
307
|
+
if not attention_point_area=='':
|
308
|
+
if isinstance(attention_point_area,list) and len(attention_point_area)>=2:
|
309
|
+
apa_list=[]
|
310
|
+
for ap in attention_point_area:
|
311
|
+
try:
|
312
|
+
appd=pd.to_datetime(ap)
|
313
|
+
except:
|
314
|
+
appd=ap
|
315
|
+
apa_list=apa_list+[appd]
|
316
|
+
|
317
|
+
yaxis_data=plt.ylim()
|
318
|
+
plt.fill_betweenx(yaxis_data,apa_list[0],apa_list[1],color='powderblue',alpha=0.5)
|
319
|
+
|
303
320
|
if average_value:
|
304
321
|
av=df[colname].mean()
|
305
322
|
plt.axhline(y=av,ls="dashed",c="blueviolet",linewidth=2,label=text_lang("均值","Mean"))
|
@@ -369,7 +386,8 @@ def plot_line2(df1,ticker1,colname1,label1, \
|
|
369
386
|
ylabeltxt,titletxt,footnote, \
|
370
387
|
power=0,datatag1=False,datatag2=False,yscalemax=5, \
|
371
388
|
zeroline=False,twinx=False, \
|
372
|
-
yline=999,
|
389
|
+
yline=999,attention_value_area='', \
|
390
|
+
xline=999,attention_point_area='', \
|
373
391
|
resample_freq='H',loc1='best',loc2='best', \
|
374
392
|
color1='red',color2='blue',facecolor='whitesmoke'):
|
375
393
|
"""
|
@@ -402,7 +420,9 @@ def plot_line2(df1,ticker1,colname1,label1, \
|
|
402
420
|
plot_line2_coaxial(df1,ticker1,colname1,label1, \
|
403
421
|
df2,ticker2,colname2,label2, \
|
404
422
|
ylabeltxt,titletxt,footnote,power,datatag1,datatag2,zeroline, \
|
405
|
-
|
423
|
+
yline=yline,attention_value_area=attention_value_area, \
|
424
|
+
xline=xline,attention_point_area=attention_point_area, \
|
425
|
+
resample_freq=resample_freq, \
|
406
426
|
loc1=loc1,loc2=loc2, \
|
407
427
|
color1=color1,color2=color2,facecolor=facecolor)
|
408
428
|
else:
|
@@ -410,7 +430,7 @@ def plot_line2(df1,ticker1,colname1,label1, \
|
|
410
430
|
df2,ticker2,colname2,label2, \
|
411
431
|
titletxt,footnote,power,datatag1,datatag2, \
|
412
432
|
resample_freq=resample_freq, \
|
413
|
-
xline=xline, \
|
433
|
+
xline=xline,attention_point_area=attention_point_area, \
|
414
434
|
loc1=loc1,loc2=loc2, \
|
415
435
|
color1=color1,color2=color2,facecolor=facecolor)
|
416
436
|
return
|
@@ -421,7 +441,9 @@ def plot2_line2(df1,ticker1,colname1,label1, \
|
|
421
441
|
df2,ticker2,colname2,label2, \
|
422
442
|
ylabeltxt,titletxt,footnote, \
|
423
443
|
power=0,datatag1=False,datatag2=False,yscalemax=5, \
|
424
|
-
zeroline=False,twinx=False,
|
444
|
+
zeroline=False,twinx=False, \
|
445
|
+
yline=999,attention_value_area='', \
|
446
|
+
xline=999,attention_point_area='', \
|
425
447
|
resample_freq='H',loc1='best',loc2='best', \
|
426
448
|
date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
|
427
449
|
color1='red',color2='blue',facecolor='whitesmoke'):
|
@@ -456,9 +478,11 @@ def plot2_line2(df1,ticker1,colname1,label1, \
|
|
456
478
|
|
457
479
|
if not twinx:
|
458
480
|
plot_line2_coaxial2(df1,ticker1,colname1,label1, \
|
459
|
-
|
481
|
+
df2,ticker2,colname2,label2, \
|
460
482
|
ylabeltxt,titletxt,footnote,power,datatag1,datatag2,zeroline, \
|
461
|
-
|
483
|
+
yline=yline,attention_value_area=attention_value_area, \
|
484
|
+
xline=xline,attention_point_area=attention_point_area, \
|
485
|
+
resample_freq=resample_freq, \
|
462
486
|
loc1=loc1,loc2=loc2, \
|
463
487
|
date_range=date_range,date_freq=date_freq,date_fmt=date_fmt, \
|
464
488
|
color1=color1,color2=color2,facecolor=facecolor)
|
@@ -466,6 +490,7 @@ def plot2_line2(df1,ticker1,colname1,label1, \
|
|
466
490
|
plot_line2_twinx2(df1,ticker1,colname1,label1, \
|
467
491
|
df2,ticker2,colname2,label2, \
|
468
492
|
titletxt,footnote,power,datatag1,datatag2, \
|
493
|
+
xline,attention_point_area=attention_point_area, \
|
469
494
|
resample_freq=resample_freq, \
|
470
495
|
loc1=loc1,loc2=loc2, \
|
471
496
|
date_range=date_range,date_freq=date_freq,date_fmt=date_fmt, \
|
@@ -480,7 +505,9 @@ def plot_line2_coaxial(df01,ticker1,colname1,label1, \
|
|
480
505
|
df02,ticker2,colname2,label2, \
|
481
506
|
ylabeltxt,titletxt,footnote, \
|
482
507
|
power=0,datatag1=False,datatag2=False,zeroline=False, \
|
483
|
-
|
508
|
+
yline=999,attention_value_area='', \
|
509
|
+
xline=999,attention_point_area='', \
|
510
|
+
resample_freq='H', \
|
484
511
|
loc1='best',loc2='best', \
|
485
512
|
color1='red',color2='blue',facecolor='whitesmoke', \
|
486
513
|
ticker_type='auto'):
|
@@ -570,11 +597,16 @@ def plot_line2_coaxial(df01,ticker1,colname1,label1, \
|
|
570
597
|
color=atv_color_list[pos]
|
571
598
|
plt.axhline(y=at,ls=":",c=color,linewidth=2,label=text_lang("关注值","Attention value ")+str(at))
|
572
599
|
|
600
|
+
if not attention_value_area=='':
|
601
|
+
if isinstance(attention_value_area,list) and len(attention_value_area)>=2:
|
602
|
+
plt.fill_between(df1.index,attention_value_area[0],attention_value_area[1],color='lightgray',alpha=0.5)
|
603
|
+
|
573
604
|
#是否绘制垂直线
|
605
|
+
import pandas as pd
|
574
606
|
if xline != 999:
|
575
607
|
attention_point=xline
|
576
608
|
#用于关注点的颜色列表
|
577
|
-
atp_color_list=["
|
609
|
+
atp_color_list=["crimson","dodgerblue","magenta","lightseagreen","chocolate"]
|
578
610
|
|
579
611
|
if isinstance(attention_point,str) or isinstance(attention_point,int) or isinstance(attention_point,float):
|
580
612
|
atp_list=[attention_point]
|
@@ -583,7 +615,7 @@ def plot_line2_coaxial(df01,ticker1,colname1,label1, \
|
|
583
615
|
else:
|
584
616
|
atp_list=[]
|
585
617
|
if not atp_list==[] and not atp_list==['']:
|
586
|
-
|
618
|
+
|
587
619
|
for at in atp_list:
|
588
620
|
pos=atp_list.index(at)
|
589
621
|
color=atp_color_list[pos]
|
@@ -598,6 +630,19 @@ def plot_line2_coaxial(df01,ticker1,colname1,label1, \
|
|
598
630
|
print("atpd=",atpd)
|
599
631
|
|
600
632
|
plt.axvline(x=atpd,ls=":",c=color,linewidth=1.5,label=text_lang("关注点","Attention point ")+str(at))
|
633
|
+
|
634
|
+
if not attention_point_area=='':
|
635
|
+
if isinstance(attention_point_area,list) and len(attention_point_area)>=2:
|
636
|
+
apa_list=[]
|
637
|
+
for ap in attention_point_area:
|
638
|
+
try:
|
639
|
+
appd=pd.to_datetime(ap)
|
640
|
+
except:
|
641
|
+
appd=ap
|
642
|
+
apa_list=apa_list+[appd]
|
643
|
+
|
644
|
+
yaxis_data=plt.ylim()
|
645
|
+
plt.fill_betweenx(yaxis_data,apa_list[0],apa_list[1],color='powderblue',alpha=0.5)
|
601
646
|
|
602
647
|
#绘证券1:制趋势线
|
603
648
|
if power > 0:
|
@@ -703,7 +748,9 @@ def plot_line2_coaxial2(df01,ticker1,colname1,label1, \
|
|
703
748
|
df02,ticker2,colname2,label2, \
|
704
749
|
ylabeltxt,titletxt,footnote, \
|
705
750
|
power=0,datatag1=False,datatag2=False,zeroline=False, \
|
706
|
-
|
751
|
+
yline=999,attention_value_area='', \
|
752
|
+
xline=999,attention_point_area='', \
|
753
|
+
resample_freq='H', \
|
707
754
|
loc1='best',loc2='best', \
|
708
755
|
date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
|
709
756
|
color1='red',color2='blue',facecolor='whitesmoke', \
|
@@ -769,6 +816,7 @@ def plot_line2_coaxial2(df01,ticker1,colname1,label1, \
|
|
769
816
|
if zeroline and ((min(df1[colname1]) < 0) or (min(df2[colname2]) < 0)):
|
770
817
|
plt.axhline(y=0,ls=":",c="black",linewidth=2.5)
|
771
818
|
|
819
|
+
"""
|
772
820
|
#是否绘制水平线
|
773
821
|
if yline != 999:
|
774
822
|
plt.axhline(y=yline,ls=":",c="black",linewidth=2.5)
|
@@ -776,6 +824,77 @@ def plot_line2_coaxial2(df01,ticker1,colname1,label1, \
|
|
776
824
|
#是否绘制垂直线
|
777
825
|
if xline != 999:
|
778
826
|
plt.axvline(x=xline,ls=":",c="black",linewidth=2.5)
|
827
|
+
"""
|
828
|
+
#是否绘制水平线
|
829
|
+
if yline != 999:
|
830
|
+
attention_value=yline
|
831
|
+
|
832
|
+
#用于关注值的颜色列表
|
833
|
+
atv_color_list=["lightgray","paleturquoise","wheat","khaki","lightsage"]
|
834
|
+
|
835
|
+
if isinstance(attention_value,int) or isinstance(attention_value,float):
|
836
|
+
atv_list=[attention_value]
|
837
|
+
elif isinstance(attention_value,list):
|
838
|
+
atv_list=attention_value
|
839
|
+
else:
|
840
|
+
atv_list=[]
|
841
|
+
|
842
|
+
if DEBUG:
|
843
|
+
print("atv_list=",atv_list)
|
844
|
+
|
845
|
+
if not atv_list==[] and not atv_list==['']:
|
846
|
+
for at in atv_list:
|
847
|
+
pos=atv_list.index(at)
|
848
|
+
color=atv_color_list[pos]
|
849
|
+
plt.axhline(y=at,ls=":",c=color,linewidth=2,label=text_lang("关注值","Attention value ")+str(at))
|
850
|
+
|
851
|
+
if not attention_value_area=='':
|
852
|
+
if isinstance(attention_value_area,list) and len(attention_value_area)>=2:
|
853
|
+
plt.fill_between(df1.index,attention_value_area[0],attention_value_area[1],color='lightgray',alpha=0.5)
|
854
|
+
|
855
|
+
#是否绘制垂直线
|
856
|
+
import pandas as pd
|
857
|
+
if xline != 999:
|
858
|
+
attention_point=xline
|
859
|
+
#用于关注点的颜色列表
|
860
|
+
atp_color_list=["crimson","dodgerblue","magenta","lightseagreen","chocolate"]
|
861
|
+
|
862
|
+
if isinstance(attention_point,str) or isinstance(attention_point,int) or isinstance(attention_point,float):
|
863
|
+
atp_list=[attention_point]
|
864
|
+
elif isinstance(attention_point,list):
|
865
|
+
atp_list=attention_point
|
866
|
+
else:
|
867
|
+
atp_list=[]
|
868
|
+
if not atp_list==[] and not atp_list==['']:
|
869
|
+
|
870
|
+
for at in atp_list:
|
871
|
+
pos=atp_list.index(at)
|
872
|
+
color=atp_color_list[pos]
|
873
|
+
|
874
|
+
#判断是否日期字符串
|
875
|
+
try:
|
876
|
+
atpd=pd.to_datetime(at)
|
877
|
+
except:
|
878
|
+
atpd=at
|
879
|
+
|
880
|
+
if DEBUG:
|
881
|
+
print("atpd=",atpd)
|
882
|
+
|
883
|
+
plt.axvline(x=atpd,ls=":",c=color,linewidth=1.5,label=text_lang("关注点","Attention point ")+str(at))
|
884
|
+
|
885
|
+
if not attention_point_area=='':
|
886
|
+
if isinstance(attention_point_area,list) and len(attention_point_area)>=2:
|
887
|
+
apa_list=[]
|
888
|
+
for ap in attention_point_area:
|
889
|
+
try:
|
890
|
+
appd=pd.to_datetime(ap)
|
891
|
+
except:
|
892
|
+
appd=ap
|
893
|
+
apa_list=apa_list+[appd]
|
894
|
+
|
895
|
+
yaxis_data=plt.ylim()
|
896
|
+
plt.fill_betweenx(yaxis_data,apa_list[0],apa_list[1],color='powderblue',alpha=0.5)
|
897
|
+
|
779
898
|
|
780
899
|
#绘证券1:制趋势线
|
781
900
|
if power > 0:
|
@@ -874,7 +993,7 @@ def plot_line2_twinx(df01,ticker1,colname1,label1, \
|
|
874
993
|
df02,ticker2,colname2,label2, \
|
875
994
|
titletxt,footnote,power=0,datatag1=False,datatag2=False, \
|
876
995
|
resample_freq='H', \
|
877
|
-
xline=999, \
|
996
|
+
xline=999,attention_point_area='', \
|
878
997
|
loc1='upper left',loc2='lower left', \
|
879
998
|
color1='red',color2='blue',facecolor='whitesmoke', \
|
880
999
|
ticker_type='auto'):
|
@@ -928,17 +1047,19 @@ def plot_line2_twinx(df01,ticker1,colname1,label1, \
|
|
928
1047
|
lwadjust=linewidth_adjust(df1)
|
929
1048
|
ax.plot(df1.index,df1[colname1],'-',label=label1txt, \
|
930
1049
|
linestyle='-',color=color1,linewidth=lwadjust)
|
1050
|
+
|
931
1051
|
#证券1:绘制数据标签
|
932
1052
|
if datatag1:
|
933
1053
|
for x, y in zip(df1.index, df1[colname1]):
|
934
1054
|
ax.text(x,y+0.1,'%.2f' % y,ha='center',va='bottom',color='black')
|
935
1055
|
|
936
1056
|
#绘制关注点
|
1057
|
+
import pandas as pd
|
937
1058
|
if xline != 999:
|
938
1059
|
attention_point=xline
|
939
1060
|
|
940
1061
|
#用于关注点的颜色列表
|
941
|
-
atp_color_list=["
|
1062
|
+
atp_color_list=["crimson","dodgerblue","magenta","lightseagreen","chocolate"]
|
942
1063
|
|
943
1064
|
if isinstance(attention_point,str) or isinstance(attention_point,int) or isinstance(attention_point,float):
|
944
1065
|
atp_list=[attention_point]
|
@@ -952,7 +1073,7 @@ def plot_line2_twinx(df01,ticker1,colname1,label1, \
|
|
952
1073
|
print("atp_list=",atp_list)
|
953
1074
|
|
954
1075
|
if not atp_list==[] and not atp_list==['']:
|
955
|
-
|
1076
|
+
|
956
1077
|
for at in atp_list:
|
957
1078
|
pos=atp_list.index(at)
|
958
1079
|
color=atp_color_list[pos]
|
@@ -964,6 +1085,19 @@ def plot_line2_twinx(df01,ticker1,colname1,label1, \
|
|
964
1085
|
atpd=at
|
965
1086
|
plt.axvline(x=atpd,ls=":",c=color,linewidth=1.5,label=text_lang("关注点","Attention point ")+str(at))
|
966
1087
|
|
1088
|
+
if not attention_point_area=='':
|
1089
|
+
if isinstance(attention_point_area,list) and len(attention_point_area)>=2:
|
1090
|
+
apa_list=[]
|
1091
|
+
for ap in attention_point_area:
|
1092
|
+
try:
|
1093
|
+
appd=pd.to_datetime(ap)
|
1094
|
+
except:
|
1095
|
+
appd=ap
|
1096
|
+
apa_list=apa_list+[appd]
|
1097
|
+
|
1098
|
+
yaxis_data=plt.ylim()
|
1099
|
+
plt.fill_betweenx(yaxis_data,apa_list[0],apa_list[1],color='powderblue',alpha=0.5)
|
1100
|
+
|
967
1101
|
#绘证券1:制趋势线
|
968
1102
|
if power > 0:
|
969
1103
|
lang=check_language()
|
@@ -1075,6 +1209,7 @@ if __name__ =="__main__":
|
|
1075
1209
|
def plot_line2_twinx2(df01,ticker1,colname1,label1, \
|
1076
1210
|
df02,ticker2,colname2,label2, \
|
1077
1211
|
titletxt,footnote,power=0,datatag1=False,datatag2=False, \
|
1212
|
+
xline=999,attention_point_area='', \
|
1078
1213
|
resample_freq='H',loc1='upper left',loc2='lower left', \
|
1079
1214
|
date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
|
1080
1215
|
color1='red',color2='blue',facecolor='whitesmoke', \
|
@@ -1146,6 +1281,52 @@ def plot_line2_twinx2(df01,ticker1,colname1,label1, \
|
|
1146
1281
|
for x, y in zip(df1.index, df1[colname1]):
|
1147
1282
|
ax.text(x,y+0.1,'%.2f' % y,ha='center',va='bottom',color='black')
|
1148
1283
|
|
1284
|
+
#绘制关注点
|
1285
|
+
import pandas as pd
|
1286
|
+
if xline != 999:
|
1287
|
+
attention_point=xline
|
1288
|
+
|
1289
|
+
#用于关注点的颜色列表
|
1290
|
+
atp_color_list=["crimson","dodgerblue","magenta","lightseagreen","chocolate"]
|
1291
|
+
|
1292
|
+
if isinstance(attention_point,str) or isinstance(attention_point,int) or isinstance(attention_point,float):
|
1293
|
+
atp_list=[attention_point]
|
1294
|
+
elif isinstance(attention_point,list):
|
1295
|
+
atp_list=attention_point
|
1296
|
+
else:
|
1297
|
+
atp_list=[]
|
1298
|
+
|
1299
|
+
if DEBUG:
|
1300
|
+
print("In plot_line2_twinx")
|
1301
|
+
print("atp_list=",atp_list)
|
1302
|
+
|
1303
|
+
if not atp_list==[] and not atp_list==['']:
|
1304
|
+
|
1305
|
+
for at in atp_list:
|
1306
|
+
pos=atp_list.index(at)
|
1307
|
+
color=atp_color_list[pos]
|
1308
|
+
|
1309
|
+
#判断是否日期字符串
|
1310
|
+
try:
|
1311
|
+
atpd=pd.to_datetime(at)
|
1312
|
+
except:
|
1313
|
+
atpd=at
|
1314
|
+
plt.axvline(x=atpd,ls=":",c=color,linewidth=1.5,label=text_lang("关注点","Attention point ")+str(at))
|
1315
|
+
|
1316
|
+
if not attention_point_area=='':
|
1317
|
+
if isinstance(attention_point_area,list) and len(attention_point_area)>=2:
|
1318
|
+
apa_list=[]
|
1319
|
+
for ap in attention_point_area:
|
1320
|
+
try:
|
1321
|
+
appd=pd.to_datetime(ap)
|
1322
|
+
except:
|
1323
|
+
appd=ap
|
1324
|
+
apa_list=apa_list+[appd]
|
1325
|
+
|
1326
|
+
yaxis_data=plt.ylim()
|
1327
|
+
plt.fill_betweenx(yaxis_data,apa_list[0],apa_list[1],color='powderblue',alpha=0.5)
|
1328
|
+
|
1329
|
+
|
1149
1330
|
#绘证券1:制趋势线
|
1150
1331
|
if power > 0:
|
1151
1332
|
lang=check_language()
|
@@ -1256,8 +1437,8 @@ def plot_line2_twinx2(df01,ticker1,colname1,label1, \
|
|
1256
1437
|
def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
1257
1438
|
data_label=True,resample_freq='H',smooth=True,linewidth=1.5, \
|
1258
1439
|
loc='best',annotate=False,annotate_value=False,plus_sign=False, \
|
1259
|
-
attention_value='', \
|
1260
|
-
attention_point='', \
|
1440
|
+
attention_value='',attention_value_area='', \
|
1441
|
+
attention_point='',attention_point_area='', \
|
1261
1442
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
1262
1443
|
ticker_type='auto',facecolor='whitesmoke'):
|
1263
1444
|
"""
|
@@ -1455,7 +1636,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1455
1636
|
#用于关注值的颜色列表
|
1456
1637
|
atv_color_list=["lightgray","paleturquoise","wheat","khaki","lightsage"]
|
1457
1638
|
#用于关注点的颜色列表
|
1458
|
-
atp_color_list=["
|
1639
|
+
atp_color_list=["crimson","dodgerblue","magenta","lightseagreen","chocolate"]
|
1459
1640
|
|
1460
1641
|
if not attention_value=='':
|
1461
1642
|
if isinstance(attention_value,int) or isinstance(attention_value,float):
|
@@ -1470,6 +1651,11 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1470
1651
|
color=atv_color_list[pos]
|
1471
1652
|
plt.axhline(y=at,ls=":",c=color,linewidth=2,label=text_lang("关注值","Attention value ")+str(at))
|
1472
1653
|
|
1654
|
+
if not attention_value_area=='':
|
1655
|
+
if isinstance(attention_value_area,list) and len(attention_value_area)>=2:
|
1656
|
+
plt.fill_between(dfg.index,attention_value_area[0],attention_value_area[1],color='lightgray',alpha=0.5)
|
1657
|
+
|
1658
|
+
import pandas as pd
|
1473
1659
|
if not attention_point=='':
|
1474
1660
|
if isinstance(attention_point,str) or isinstance(attention_point,int) or isinstance(attention_point,float):
|
1475
1661
|
atp_list=[attention_point]
|
@@ -1478,7 +1664,7 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1478
1664
|
else:
|
1479
1665
|
atp_list=[]
|
1480
1666
|
if not atp_list==[] and not atp_list==['']:
|
1481
|
-
|
1667
|
+
|
1482
1668
|
for at in atp_list:
|
1483
1669
|
pos=atp_list.index(at)
|
1484
1670
|
color=atp_color_list[pos]
|
@@ -1508,6 +1694,19 @@ def draw_lines(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1508
1694
|
width=0.05,length_includes_head=True)
|
1509
1695
|
"""
|
1510
1696
|
plt.axvline(x=atpd,ls=":",c=color,linewidth=1.5,label=text_lang("关注点","Attention point ")+str(at))
|
1697
|
+
|
1698
|
+
if not attention_point_area=='':
|
1699
|
+
if isinstance(attention_point_area,list) and len(attention_point_area)>=2:
|
1700
|
+
apa_list=[]
|
1701
|
+
for ap in attention_point_area:
|
1702
|
+
try:
|
1703
|
+
appd=pd.to_datetime(ap)
|
1704
|
+
except:
|
1705
|
+
appd=ap
|
1706
|
+
apa_list=apa_list+[appd]
|
1707
|
+
|
1708
|
+
yaxis_data=plt.ylim()
|
1709
|
+
plt.fill_betweenx(yaxis_data,apa_list[0],apa_list[1],color='powderblue',alpha=0.5)
|
1511
1710
|
|
1512
1711
|
#绘制水平辅助线
|
1513
1712
|
if axhline_label !="":
|
@@ -1558,9 +1757,14 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1558
1757
|
data_label=False,resample_freq='6H',smooth=True, \
|
1559
1758
|
date_range=False,date_freq=False,date_fmt='%Y-%m-%d', \
|
1560
1759
|
colorlist=[],lslist=[],lwlist=[], \
|
1760
|
+
#指定纵轴两个变量之间的区域
|
1561
1761
|
band_area='',loc='best', \
|
1562
1762
|
attention_value='', \
|
1763
|
+
#指定纵轴两个数值之间的区域
|
1764
|
+
attention_value_area='', \
|
1563
1765
|
attention_point='', \
|
1766
|
+
#指定两个横轴之间的区域
|
1767
|
+
attention_point_area='', \
|
1564
1768
|
annotate=False,annotate_value=False, \
|
1565
1769
|
mark_top=False,mark_bottom=False,mark_end=False, \
|
1566
1770
|
facecolor='whitesmoke'):
|
@@ -1757,8 +1961,10 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1757
1961
|
plt.fill_between(df.index,df[upper_line],df[lower_line],color='moccasin',alpha=0.5,label='',where=df[upper_line]>=df[lower_line])
|
1758
1962
|
plt.fill_between(df.index,df[upper_line],df[lower_line],color='aquamarine',alpha=0.5,label='',where=df[upper_line]<=df[lower_line])
|
1759
1963
|
"""
|
1760
|
-
plt.fill_between(df.index,df[upper_line],df[lower_line],color='aquamarine',alpha=0.5,label='')
|
1761
|
-
|
1964
|
+
#plt.fill_between(df.index,df[upper_line],df[lower_line],color='aquamarine',alpha=0.5,label='')
|
1965
|
+
plt.fill_between(df.index,df[upper_line],df[lower_line],df[upper_line] > df[lower_line],color='aquamarine',alpha=0.5,label='',interpolate=True)
|
1966
|
+
plt.fill_between(df.index,df[upper_line],df[lower_line],df[upper_line] < df[lower_line],color='lightcoral',alpha=0.5,label='',interpolate=True)
|
1967
|
+
#plt.fill_between(df.index,df[upper_line],df[lower_line],df[upper_line] == df[lower_line],color='lightgray',alpha=0.5,label='')
|
1762
1968
|
|
1763
1969
|
#绘制水平辅助线
|
1764
1970
|
if axhline_label !="":
|
@@ -1773,7 +1979,7 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1773
1979
|
#用于关注值的颜色列表
|
1774
1980
|
atv_color_list=["lightgray","paleturquoise","wheat","khaki","lightsage"]
|
1775
1981
|
#用于关注点的颜色列表
|
1776
|
-
atp_color_list=["
|
1982
|
+
atp_color_list=["crimson","dodgerblue","magenta","lightseagreen","chocolate"]
|
1777
1983
|
|
1778
1984
|
if not attention_value=='':
|
1779
1985
|
if isinstance(attention_value,int) or isinstance(attention_value,float):
|
@@ -1788,6 +1994,11 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1788
1994
|
color=atv_color_list[pos]
|
1789
1995
|
plt.axhline(y=at,ls=":",c=color,linewidth=2,label=text_lang("关注值","Attention value ")+str(at))
|
1790
1996
|
|
1997
|
+
if not attention_value_area=='':
|
1998
|
+
if isinstance(attention_value_area,list) and len(attention_value_area)>=2:
|
1999
|
+
plt.fill_between(df.index,attention_value_area[0],attention_value_area[1],color='lightgray',alpha=0.5)
|
2000
|
+
|
2001
|
+
import pandas as pd
|
1791
2002
|
if not attention_point=='':
|
1792
2003
|
if isinstance(attention_point,str) or isinstance(attention_point,int) or isinstance(attention_point,float):
|
1793
2004
|
atp_list=[attention_point]
|
@@ -1796,7 +2007,6 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1796
2007
|
else:
|
1797
2008
|
atp_list=[]
|
1798
2009
|
if not atp_list==[] and not atp_list==['']:
|
1799
|
-
import pandas as pd
|
1800
2010
|
for at in atp_list:
|
1801
2011
|
pos=atp_list.index(at)
|
1802
2012
|
color=atp_color_list[pos]
|
@@ -1807,6 +2017,19 @@ def draw_lines2(df0,y_label,x_label,axhline_value,axhline_label,title_txt, \
|
|
1807
2017
|
except:
|
1808
2018
|
atpd=at
|
1809
2019
|
plt.axvline(x=atpd,ls=":",c=color,linewidth=1.5,label=text_lang("关注点","Attention point ")+str(at))
|
2020
|
+
|
2021
|
+
if not attention_point_area=='':
|
2022
|
+
if isinstance(attention_point_area,list) and len(attention_point_area)>=2:
|
2023
|
+
apa_list=[]
|
2024
|
+
for ap in attention_point_area:
|
2025
|
+
try:
|
2026
|
+
appd=pd.to_datetime(ap)
|
2027
|
+
except:
|
2028
|
+
appd=ap
|
2029
|
+
apa_list=apa_list+[appd]
|
2030
|
+
|
2031
|
+
yaxis_data=plt.ylim()
|
2032
|
+
plt.fill_betweenx(yaxis_data,apa_list[0],apa_list[1],color='powderblue',alpha=0.5)
|
1810
2033
|
|
1811
2034
|
#坐标轴标记
|
1812
2035
|
plt.ylabel(y_label,fontweight='bold',fontsize=ylabel_txt_size)
|