pyplot数据展示

import matplotlib.pyplot as plt
import pandas as pd
from pylab import *

mpl.rcParams['font.sans-serif'] = ['SimHei']

file = pd.read_csv('./students.csv')
x_boy = []
y_boy = []
x_girl = []
y_girl = []

for i in range(0, file.shape[0]):
    if file.values[i][0] == 1:
        x_boy.append(file.values[i][1])
        y_boy.append(file.values[i][2])
    else:
        x_girl.append(file.values[i][1])
        y_girl.append(file.values[i][2])

plt.scatter(x_boy, y_boy, marker='*', c='red', label='boy')
plt.scatter(x_girl, y_girl, c='blue', label='girl')
plt.xlim(100, 160)
plt.ylim(15, 50)
plt.title('身高和体重')
plt.xlabel('身高')
plt.ylabel('体重')
plt.legend(loc='upper left')

plt.show()

pyplot数据展示_第1张图片

你可能感兴趣的:(python,numpy)