3、有颜色棒的散点图
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
rng = np.random.RandomState(0)
x = rng.randn(50)
y = rng.randn(50)
colors = rng.rand(50)
sizes = 500 * rng.rand(50)
plt.scatter(x, y, c=colors, s=sizes, alpha=0.4,
cmap='viridis')
plt.colorbar()
# 右边有颜色棒
plt.xlabel("x轴")
plt.ylabel("y轴")
plt.title("有颜色棒的散点图")
plt.show()
# 显示图形