国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
【數(shù)字的可視化:python畫圖之散點(diǎn)圖sactter函數(shù)詳解】

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

1、scatter函數(shù)原型

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

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

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

[python] view plain copy
  1. #導(dǎo)入必要的模塊  
  2. import numpy as np  
  3. import matplotlib.pyplot as plt  
  4. #產(chǎn)生測(cè)試數(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. #畫散點(diǎn)圖  
  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中的每個(gè)點(diǎn)對(duì)應(yīng)s中一個(gè)大小,其他如c,等用法一樣,如下:

(1)、不同大小

[python] view plain copy
  1. #導(dǎo)入必要的模塊  
  2. import numpy as np  
  3. import matplotlib.pyplot as plt  
  4. #產(chǎn)生測(cè)試數(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. #畫散點(diǎn)圖  
  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)、不同顏色

[python] view plain copy
  1. #導(dǎo)入必要的模塊  
  2. import numpy as np  
  3. import matplotlib.pyplot as plt  
  4. #產(chǎn)生測(cè)試數(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. #畫散點(diǎn)圖  
  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

[python] view plain copy
  1. #導(dǎo)入必要的模塊  
  2. import numpy as np  
  3. import matplotlib.pyplot as plt  
  4. #產(chǎn)生測(cè)試數(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. #畫散點(diǎn)圖  
  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基本的用法。





本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
python 畫散點(diǎn)圖
三維散點(diǎn)圖
python數(shù)據(jù)分析工具之 matplotlib詳解
一次性掌握所有 Python 畫圖基礎(chǔ)操作
python數(shù)據(jù)可視化 | matplotlib.pyplot()函數(shù)繪制散點(diǎn)圖
Python Matplotlib散點(diǎn)圖
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服