1.源代码
#coding=utf-8
import numpy as np;
import matplotlib.pyplot as plt;
import math;
fig = plt.figure(figsize=(4,4))
ax = fig.add_subplot(111);
girls_grades = [89,90,70,89,100,80,90,100,80,34]
boys_grades = [30,29,49,48,100,48,38,45,20,30]
grade_range = [10,20,30,40,50,60,70,80,90,100]
plt.scatter(grade_range, girls_grades, c='lightgreen', alpha=0.5)
plt.scatter(grade_range, boys_grades, c='skyblue', alpha=0.5)
plt.grid(False)
plt.savefig('scatter.png');
2.运行程序
$ python scatter.py
3.绘制结果
scatter.png