matplotlib基本関数


    
    matlab
    Numpy + scipy + pandas +matplotlib
         +    +    +     
1 Numpy  
    1   c   python        
    2     
    3    python            
    4                
2 Numpy   
    12         ,      
      :
        1   
        2 Numpy     ndarray       :
                :     
               :      
                               ,        
        3 Numpy          ,                
        4 dtype shape             
        5    
            np.arange(   ,   ,  )
                 0
                :1
            np.array(            )
        6     astype(    )->       
        7 ''      ,              21 Unicode  
    3          
                    :(    ->    )
            ,6   :(6,)
            ,2 3 :(2,3)
            ,2 3 4 :(2,3,41                
            2   [  ][  ][  ]
            31     
                       
                    bool_ : True/False
                      
                        :int8/int16/int32/int64
                        : uint8/uint16/uint32/uin64
                       : float16/float32/float64
                        :complex64/complex128
                2     
                                        
                    np.array(..,dytpe=    )
                3      
                    bool_:?
                         :i1/2/4/8
                         :u1/2/4/8
                       : f2/4/8
                       :c8/16
                       :U
                        :M
                       (       ):>/=    /  /  
                4   
                      [  :  :  ]
                        : (   )/ (   )
                        :  (   )/  
                        :1
                5   
                    1     :     ,      
                        1   .reshape(   ) ->   
                                   
                        2   .ravel() ->         
                        3     :             
                              .flatten() -->     (        )
                        4     :       (    ,          )
                              .shape =    
                              .resize(   )
                6      
                    1     :                      
                        np.vstack(( , ))
                    
                        np.concatenate(( , ),axis=0) 
                            axis :   ,         0  ,,1  
                    2     :                      
                        np.hstack(( , ))
                        np.concatenate(( , ),axis=1)
                    3     :                      
                        np.dstack(( , ))     
                    4    :                      
                        np.row_stack(( , ))
                    5    :                      
                        np.column_stack(( , ))
                    6     :                         
                        np.vsplit(     ,    )
                        np.split(     ,    ,axis=0)
                    7     :                         
                        np.hsplit(     ,    )
                        np.split(     ,    ,axis=1)
                    8     :                         
                        np.dsplit(     ,    )
                7 ndarray   
                    dtype -       
                    shape -      
                    ndim -      ,len(shape)
                    size -       ,shape     
                    itemsize -      , dtype  
                    nbytes -     ,size x itemsize
                    T -     
                    real -          
                    imag -          
                    flat -      
                8 ndarray <==>list
                    np.array(  )
                        
 :     (Matplotlib)
    1     
        plot(    ,    )
    2   ,     
        plot(...,linestyle=  ,linewidth=  ,color=  ,...)
          :[-]/--/:./o/o-/...
          :0-oo
        color:dodgerblue/orangeered/limegreen/red/blue/...
    3       
        xlim(       ,       )
        ylim(       ,       )
              ,    ,    。
    4       
        xticks([       ])  
        yticks([       ])
               pi(  [r'$-\pi$']   )
            2  pi (  r'$-\frac{\pi}{2}$'  )
    5        
        ax = gca() #         
        ax.spines['left'] -    
            ax.spines['left'].set_position(('data', 0))
        ax.spines['right'] -    
        ax.spines['top'] -    
        ax.spines['bottom'] -    
        XX .set_position((   ,   )) #    
            
        XX .set_color(  ) #    
            ax.spines['top'].set_color('none')
    6   
        plot(...,label=    ,...)
        legend([loc=    ])
    7     
        scatter(    ,    ,s=  ,marker=  ,
            edgecolor=   ,facecolor=   ,zorder=Z  )
    8   
        annotate(
                ,
            xy =    ,
            xycoords =     ,
            xytext=    ,
            textcoords=     ,
            fontsize=    ,
            arrowprops=    )
    9   (  )  
        figure(   (     ),figsize=  ,dip=   ,facecolor=  )
                          ,           ,     ,           ,                    
        title(    ,fontsize=    )
        xlabel(     ,fontsize=    )
        tick_params(labelsize=        )
        grid(linestyle=    )
    10     
        1     
            subplot(  ,  ,  )
            tight_layout() #    
        2     
                  = mp.GridSpec(  ,  )
            subplot(     [ , ]
            
        3     
            axes([ , , , ]) #      
    11      
        xxxLocator(    )
        ax = gca()
        ax.xaxis      
        ax.yaxis      
           .set_major_locator(     ) #   
           .set_minor_locator(     ) #   
        mp.axis('off') #     
    12     
        fill_between(    ,      ,      ,color=  ,alpha=       )
    13    
        bar(    ,    ,    ,color=  ,label=    ,alpha=   )
    14   
        pie(   ,    ,    ,    ,shadow =     ,startangle=    )
    15     
        contour(  X    ,  Y    ,  Z    ,   ,colors=  ,linewidths=  )
    16    
    
    17    
        ax = gca()
        ax.grid(which="major/minor",axis='x/y/both')
    18      
        semi( plot)
    19    
        gca(projection='polar') #      
        plot/scatter(  ,  )
    20      
        from mp;_toolkits.mplot3d import axes3d
        1     
            ax.scatter(x  ,Y  ,Z  ,s=   ,marker=   ,
                        edgecolor=   ,fancecolor=   ,
                        zorder=Z  )
        2     
            ax.plot_surface(  X  ,  Y    ,  Z    ,rstride=   ,
                            cstride=   ,cmap=    )
            ax.plot_wireframe(  X    ,  Y    ,  Z    ,
                            rstride=   ,cstride=   ,linewidth=  ,color=  )

 
転載先:https://www.cnblogs.com/Skyda/p/10071194.html