用Python學分析 - 散點圖

# 運用散點圖對數據分佈獲得直觀的認識數組

 1 import numpy as np
 2 import matplotlib.pyplot as plt
 3 
 4 # 設計 x, y 軸
 5 n = 10000
 6 x = np.random.randn( n ) # 隨機值
 7 y = np.random.randn( n )
 8 
 9 # 顯示散點圖
10 colors = ['b','r','g','y','k','m']
11 plt.scatter(x, y, c = colors, marker = 'p', alpha=0.5 )
12 plt.title('Distribution')
13 plt.show()
14 
15 # scatter( x, y, s = None, c = None, maker = None,
16 #          camp = None, norm = None, vmin = None, vmax = None, 
17 #          alpha = None, linewidth = None, vert = None, edgecolors = None,
18 #          hold = None, data = None, **kwargs
19 #        )
20 # x,y   - 形如shape(n,)的數組,可選值
21 # s - 點的大小(也就是面積)默認20
22 # c [color] - 點的顏色或顏色序列,默認藍色。其它如c = 'r' (red); c = 'g' (green); c = 'k' (black) ; c = 'y'(yellow)
23 # marker 形狀,可選值,默認是圓 [. , _ o v ^ < > 1 2 3 4 8 s p P * h H + x X D]
24 
25 # alpha - 透明度,標量,可選,默認值:無, 0(透明)和1(不透明)之間的alpha混合值
26 # edgecolors - 邊緣顏色或顏色序列,可選值,默認值:None
View Code

散點圖結果:dom

結論:ide

從圖像上看,散點呈均勻分佈。spa

相關文章
相關標籤/搜索