py matplotlib plurality figure and a plurality of simultaneously drawing a plurality of legends FIG plurality of line graphs

Need to read data template file format, the subsequent first name to be displayed, then the cost, net, using {/} partition

CCB 50 | 0.8502 / 0.8499 / 0.8496 | 0.8263 / 0.8239 / 0.8253 | 0.0260 / 0.0246 
Wells Fargo CKS bonus | 1.1273 / 1.1270 / 1.1263 | 1.1030 / 1.1040 / 1.0960 | 0.0230 / 0.0310 
Invesco CKS 500   | 0.9798 / .9792 / 0.9780 | .9271 /0.9250/0.9149 | 0.0542 / 0.0643 
sea before the open-source AI | 1.0665 / 1.0653 / 1.0625 | 0.9930 / 0.9890 / 0.9870 | 0.0763 
easy to square up the GEM | 1.6463 / 1.6452 / 1.6434 | 1.5368 / 1.5377 / 1.5233 | 0.1075 
Southern value mixed C | 1.0843 /1.0837/1.0819 | 1.0520 / 1.0520 / 1.0490 | 0.0317
# - * - Coding: UTF-. 8 - * - 
Import numpy AS NP  
 Import matplotlib.pyplot AS PLT
 Import   matplotlib 

font = {
     ' Family ' : ' SimHei ' 
} 
matplotlib.rc ( ' font ' , ** font) 

[ " 006 539 " , " NFYXJZHHC " , " South preferred value mixed C " , " hybrid " , " NANFANGYOUXUANJIAZHIHUNHEC "]
["100032 " , " FGZZHLZSZQ " , " rich in the SSE Dividend Index enhancement " , " stock index " , " FUGUOZHONGZHENGHONGLIZHISHUZENGQIANG " ] 
[ " 003 318 " , " JSZZ500HYZXDBD " , " Invesco CSI 500 Sector Neutral low volatility " , " stock index " , " JINGSHUNZHONGZHENG500HANGYEZHONGXINGDIBODONG " ] 
[ " 001 986 " , "QHKYRGZNZTHH","Open Source AI theme mixed before the sea " , " hybrid " , " QIANHAIKAIYUANRENGONGZHINENGZHUTIHUNHE " ] 
[ " 004 744 " , " YFDCYBETFLJC " , " easy side of the GEM ETF joins C " , " feeder funds " , " YIFANGDACHUANGYEBANETFLIANJIEC " ] 
[ " 165 312 " , " JXYS50 " , " CCB CCTV 50 " , " stock index ", " JIANXINYANGSHI50"]
i=1
index=321
subIndex=321
def calc(value):
    global index
    day="6-1,6-2,6-3".split(',')
    #v="建信50 | 0.8502/0.8499/0.8496    | 0.8263/0.8239/0.8253 | 0.0260/0.0246".split('|')
    v=value.split('|')
    name=v[0]
    myValue=[]
    for m in v[1].split('/'):
        myValue.append(float(m))
    curValue = []
     for m in V [2] .split ( ' / ' ): 
        curValue.append (a float (m)) 
    Z = []
     # finishing difference data 
    for I in Range (len (Day)): 
        Z. the append ((the myValue [I] -curValue [I]) * 10 ) 
    
    plt.figure ( . 1 ) 
    plt.subplot (index) 
    plt.plot (Day, the myValue, Color = ' Blue ' , as linewidth = 2.0, lineStyle = ' - ' , = label positions cost " )"
    plt.plot (Day, curValue, Color = ' Red ' , as linewidth = 2.0, lineStyle = ' - ' , label = " Current Net " ) 
    plt.legend ()   # shown above label 
    plt.title (name) # Add title 

    plt.figure ( 2 ) 
    plt.subplot (index) 
    plt.plot (Day, Z, Color = ' Red ' , as linewidth = 2.0, lineStyle = ' - ' , label = " difference value " ) 
    plt.legend ()   # the label shown above
    plt.title (name + " difference value " ) # Add a title 
    index = index +. 1 return Z DEF Sub (name, value): 
    plt.figure ( . 1 ) 
    plt.subplot (index) 
    index = index +. 1 
    plt.plot (Day , value, Color = ' Red ' , as linewidth = 2.0, lineStyle = ' - ' , label = " difference value " ) 
    plt.legend ()   # shown above label 
    plt.title (name + " difference value " ) # add title     
with open (
    



"./a.txt",'r', encoding='UTF-8') as file:
    for line in file:
        z=calc(line)
        name=(line.split('|'))[0]
        #print(name)
plt.show()

 

Guess you like

Origin www.cnblogs.com/ives/p/10974990.html
Recommended