python_pandas_matplolib绘图(1)
In [1]:df = df.drop(['new_score'], axis=1) In [2]:df.head(2) Out[2]:
序号 | 姓名 | 性别 | 语文 | 数学 | 英语 | 物理 | 化学 | 生物 | 数学分类 | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | jin | 女 | 95 | 76 | 85 | 75 | 79 | 89 | 良 |
1 | 2 | li | 男 | 88 | 87 | 68 | 92 | 82 | 63 | 优秀 |
绘图
In [3]:import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline #必不可少,图画在notebook 中
In [4]:x = np.linspace(0,10,100)
y = np.sin(x)
plt.plot(x,y)
plt.plot(x, np.cos(x))
plt.show()
In [5]:plt.plot(x,y, '*')
plt.show()
In [6]:fig = plt.figure()
plt.plot(x,y, '-')
plt.show()
In [7]:fig.savefig('C:/Users/Administrator/sin.png')
subplot用法:将2个图显示在一个图内
#subplot(2,1,1)2行一列,图1
#subplot(2,1,2)2行一列,图2
In [8]:fig = plt.figure()
plt.subplot(2,1,1)
plt.plot(x, np.sin(x),'--')
plt.subplot(2,1,2)
plt.plot(x, np.cos(x))
plt.show()
fig.savefig('C:/Users/Administrator/sincos.png')