Scatter
- 表达形式
matplotlib.pyplot.scatter(x, y, s=20, c=None, marker='o',...)
- 参数
1、x/y:array_like, shape (n, ),
input data
2、s:scalar or array_like, shape (n, ), optional, default: 20
size in points^2
3、c:color, sequence, or sequence of color, optional, default: ‘b’
c can be a single color format string, or a sequence of color specifications of length N
- Example
import numpy as np
import matplotlib.pyplot as plt
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N) #作为序列时,数目应与x长度相同
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radiuses。半径在0-15之间,area为面积的平方。也可使用标量统一大小
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()