散点图


Matplotlib散点图

import matplotlib.pyplot as plt
import matplotlib

# 设置中文字体
matplotlib.rcParams['axes.unicode_minus'] = False
matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei']
matplotlib.rcParams['font.family']='sans-serif'

x = [1,2,3,4,5,6,7,8]
y = [5,2,4,2,1,4,5,2]
plt.scatter(x,y, label='散点', color='r', s=25, marker=".")
# 颜色、直径、形状
# http://matplotlib.org/api/markers_api.html
plt.xlabel('x')
plt.ylabel('y')
plt.title('编程字典-matplotlib教程')
plt.legend()
plt.show()