带有图例的散点图
还演示了如何通过给alpha值介于0和1之间来调整标记的透明度。

import matplotlib.pyplot as pltfrom numpy.random import randfig, ax = plt.subplots()for color in ['red', 'green', 'blue']:n = 750x, y = rand(2, n)scale = 200.0 * rand(n)ax.scatter(x, y, c=color, s=scale, label=color,alpha=0.3, edgecolors='none')ax.legend()ax.grid(True)plt.show()
