散点图¶
当您的数据没有序列,但仍以数据点为特征时,可以选择所谓的散点图。命令是 scatter()
像这样使用时
import matplotlib.pyplot as plt
import numpy as np
# Generate data for the plot
r = np.random.RandomState(42)
x = r.random_sample(10)
y0 = r.random_sample(10)
y1 = r.random_sample(10)
# Generate the plot
fig, ax = plt.subplots()
ax.scatter(x, y0)
ax.scatter(x, y1)
plt.show(fig)
它会生成一个显示不同数据点组的图: