python利用scatter繪畫散點圖
scatter繪畫散點圖代碼如下:
import matplotlib.pyplot as plt plt.scatter(x,y, s = 20 c='b' marker=‘o' cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, )
import numpy as np import pandas as pd import matplotlib.pyplot as plt x=np.random.randint(0,10,10) y=np.random.randint(0,10,10) print(x) print(y) plt.scatter(x,y,s=50)默認形狀圓點,顏色b 藍色,大小50
out:
[5 1 5 3 1 5 0 5 4 7]
[8 2 7 7 8 6 3 8 5 9]
import numpy as np import pandas as pd import matplotlib.pyplot as plt x = np.array([[0,0],[0,1],[1,1],[3,2],[-2,3],[1,2],[4,3]]) print(x) plt.scatter(x[:,0],x[:,1],marker='x',color='k',s=20)#點的形狀x,顏色黑色,大小20
out:
[[ 0 0]
[ 0 1]
[ 1 1]
[ 3 2]
[-2 3]
[ 1 2]
[ 4 3]]
到此這篇關於python利用scatter繪畫散點圖的文章就介紹到這瞭,更多相關python scatter繪畫內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!
推薦閱讀:
- python scatter繪制散點圖
- Python matplotlib 繪制散點圖詳解建議收藏
- Matplotlib配色之Colormap詳解
- Python數據分析之matplotlib繪圖詳解
- python數學建模之Matplotlib 實現圖片繪制