Data Analysis 3 - sketch

matplotlib 
    plt.plot () # drawing function 
    plt.show () # display image 
    
    . 1 .plot functions: line graph 
        line lineStyle ( -, - -,. , ..) 
        point type marker (V, ^, S, *, H, + , X-, D, O, ...) 
        color color (B, G, R & lt, Y, K, W, ...) 
        
        plt.plot ([ 0 , . 3 , . 9 , 15 , 30 ] , lineStyle = ' -. ' , Color = ' R & lt ' , marker = ' O ' ) 
        
    2 conventional method. 
        plt.plot ([ 0 , . 3 , . 9 ,15,30],linestyle = '-.',color = 'r',marker = 'o',label="A") 
        plt.plot([1,3,16,23,30],[30,23,13,25,30],label='B')
        plt.title("Title")  # 标题
        plt.xlabel('X- ' ) # X-axis name 
        plt.ylabel ( ' the Y ' ) # Y axis name 
        plt.xticks (np.arange ( 0 , 30 , 2 )) # X axis scale 
        plt.xlim ( - 0.2 , 10 , 2 ) # The x-axis range 
        plt.legend () # plot legend 
        
    3 histogram 
        Data = [ 12 is , 34 is , 23 is , 54 is ] 
        Labels = [ ' Jan ' , ' the Fed ' , ' -Mar' , ' On Apr ' ] 
        plt.xticks ([ 0 , . 1 , 2 , . 3 ], Labels) # x axis scale is provided 
        plt.bar ([ 0 , . 1 , 2 , . 3 ], Data)   
        
    . 4 . Histogram lateral 
        Data = [ 12 is , 34 is , 23 is , 54 is ] 
        Labels = [ ' Jan ' , ' the Fed ' , ' -Mar ' , ' On Apr ']
        plt.yticks([0,1,2,3],labels)
        plt.barh([0,1,2,3],data)      
                    
    5.饼图
        plt.pie([10,20,30,40],labels=list('abcd'),autopct="%.2f%%",explode=[0.1,0,0,0]) 
        plt.axis("equal")
        plt.show ()     

    . 6 . scattergram 
        Import Random 
        X = np.random.randn ( 100 ) 
        Y = np.random.randn ( 100 ) 
        plt.scatter (X, Y)

 

Guess you like

Origin www.cnblogs.com/wyf20190411-/p/12013409.html
Recommended