[TOC]
# plot折线图
~~~
%matplotlib inline
import pandas as pd
import numpy as np
s = pd.Series(np.random.randn(10), index=np.arange(0, 100, 10))
s.plot()
~~~
![](https://box.kancloud.cn/0166574c615ccac587d25e42bae0edd2_794x512.png)
~~~
df = pd.DataFrame(np.random.randn(10, 4).cumsum(0), index=np.arange(0, 100, 10), columns=['A', 'B', 'C', 'D'])
df.plot()
~~~
输出
![](https://box.kancloud.cn/2e1e680197bac45e469506d71323e847_752x506.png)
# 子图
~~~
import matplotlib.pyplot as plt
# 子图是2行1列的
fig,axes = plt.subplots(2, 1)
data = pd.Series(np.random.rand(16), index = list('abcdefghijkmlnop'))
# bar竖着画柱形图,barh横着画
data.plot(ax = axes[0], kind='bar')
data.plot(ax = axes[1], kind='barh')
~~~
![](https://box.kancloud.cn/d1f4411a3ff1229d0865c944a8cdac2f_824x534.png)
# 柱状图
~~~
df = pd.DataFrame(np.random.rand(6,4),
index=['one', 'two', 'three', 'four', 'five', 'six'],
columns = pd.Index(['A', 'B', 'C', 'D'], name='Genus'))
df.plot(kind='bar')
~~~
![](https://box.kancloud.cn/d3ef62d837ce0b69ef81925b132ec55b_808x572.png)
# 直方图
查看某个属性的直方图
~~~
# bins是50个小区域,hist是直方图
df.A.plot(kind='hist', bins=50)
~~~
![](https://box.kancloud.cn/1c103aa62306c1e3c61ead0a322aa78a_846x520.png)
# 散点图
~~~
df.plot.scatter('A', 'B')
~~~
![](https://box.kancloud.cn/60f83af052e1039ade02ff1d2768eed9_828x560.png)