用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
散点图结果:
结论:
从图像上看,散点呈均匀分布。