乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      python 散點圖

       wenasunny 2018-08-09

      最近開始學(xué)習(xí)python編程,遇到scatter函數(shù),感覺里面的參數(shù)不知道什么意思于是查資料,最后總結(jié)如下:

      1、scatter函數(shù)原型

      2、其中散點的形狀參數(shù)marker如下:

      3、其中顏色參數(shù)c如下:

      4、基本的使用方法如下:

      1. #導(dǎo)入必要的模塊  
      2. import numpy as np  
      3. import matplotlib.pyplot as plt  
      4. #產(chǎn)生測試數(shù)據(jù)  
      5. x = np.arange(1,10)  
      6. y = x  
      7. fig = plt.figure()  
      8. ax1 = fig.add_subplot(111)  
      9. #設(shè)置標(biāo)題  
      10. ax1.set_title('Scatter Plot')  
      11. #設(shè)置X軸標(biāo)簽  
      12. plt.xlabel('X')  
      13. #設(shè)置Y軸標(biāo)簽  
      14. plt.ylabel('Y')  
      15. #畫散點圖  
      16. ax1.scatter(x,y,c = 'r',marker = 'o')  
      17. #設(shè)置圖標(biāo)  
      18. plt.legend('x1')  
      19. #顯示所畫的圖  
      20. plt.show()  

      結(jié)果如下:

      5、當(dāng)scatter后面參數(shù)中數(shù)組的使用方法,如s,當(dāng)s是同x大小的數(shù)組,表示x中的每個點對應(yīng)s中一個大小,其他如c,等用法一樣,如下:

      (1)、不同大小

      1. #導(dǎo)入必要的模塊  
      2. import numpy as np  
      3. import matplotlib.pyplot as plt  
      4. #產(chǎn)生測試數(shù)據(jù)  
      5. x = np.arange(1,10)  
      6. y = x  
      7. fig = plt.figure()  
      8. ax1 = fig.add_subplot(111)  
      9. #設(shè)置標(biāo)題  
      10. ax1.set_title('Scatter Plot')  
      11. #設(shè)置X軸標(biāo)簽  
      12. plt.xlabel('X')  
      13. #設(shè)置Y軸標(biāo)簽  
      14. plt.ylabel('Y')  
      15. #畫散點圖  
      16. sValue = x*10  
      17. ax1.scatter(x,y,s=sValue,c='r',marker='x')  
      18. #設(shè)置圖標(biāo)  
      19. plt.legend('x1')  
      20. #顯示所畫的圖  
      21. plt.show()  

      (2)、不同顏色

      1. #導(dǎo)入必要的模塊  
      2. import numpy as np  
      3. import matplotlib.pyplot as plt  
      4. #產(chǎn)生測試數(shù)據(jù)  
      5. x = np.arange(1,10)  
      6. y = x  
      7. fig = plt.figure()  
      8. ax1 = fig.add_subplot(111)  
      9. #設(shè)置標(biāo)題  
      10. ax1.set_title('Scatter Plot')  
      11. #設(shè)置X軸標(biāo)簽  
      12. plt.xlabel('X')  
      13. #設(shè)置Y軸標(biāo)簽  
      14. plt.ylabel('Y')  
      15. #畫散點圖  
      16. cValue = ['r','y','g','b','r','y','g','b','r']  
      17. ax1.scatter(x,y,c=cValue,marker='s')  
      18. #設(shè)置圖標(biāo)  
      19. plt.legend('x1')  
      20. #顯示所畫的圖  
      21. plt.show()  

      結(jié)果:

      (3)、線寬linewidths

      1. #導(dǎo)入必要的模塊  
      2. import numpy as np  
      3. import matplotlib.pyplot as plt  
      4. #產(chǎn)生測試數(shù)據(jù)  
      5. x = np.arange(1,10)  
      6. y = x  
      7. fig = plt.figure()  
      8. ax1 = fig.add_subplot(111)  
      9. #設(shè)置標(biāo)題  
      10. ax1.set_title('Scatter Plot')  
      11. #設(shè)置X軸標(biāo)簽  
      12. plt.xlabel('X')  
      13. #設(shè)置Y軸標(biāo)簽  
      14. plt.ylabel('Y')  
      15. #畫散點圖  
      16. lValue = x  
      17. ax1.scatter(x,y,c='r',s= 100,linewidths=lValue,marker='o')  
      18. #設(shè)置圖標(biāo)  
      19. plt.legend('x1')  
      20. #顯示所畫的圖  
      21. plt.show()  


                           注:  這就是scatter基本的用法。             

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多