subplot2grid用法详解
#! /user/bin/env python
#_*_coding:utf-8 -*_
#__author__ = '株洲市易美智能工程有限责任公司'
#Email:yizhi8.@qq.com
#微信:yizhi8
import matplotlib.pyplot as plt
import tushare as ts
stock = '000001'
fig_shap = (3,3)#图片分割为3*3
fig = plt.figure(stock+'的成交量、开盘、收盘、最低、最高',figsize=(15,13),facecolor='r')#设置图片的名称,大小、底色
plt.rcParams['font.sans-serif'] = ['SimHei']#设置中文的字体
df = ts.get_k_data(stock,ktype='D')#采集数据
fig_volume = plt.subplot2grid(fig_shap,(0,0),colspan= 3)#设置图片分割为3*3,当前图片在0,0占三0行的3列
fig_volume.plot(df.volume)#设置数据
plt.title(stock+'的成交额')#设置小图片的名称
fig_open = plt.subplot2grid(fig_shap,(1,0),colspan=2)
fig_open.plot(df.open)
plt.title(stock+'的开盘价曲线')
fig_close = plt.subplot2grid(fig_shap,(1,2,),rowspan=2)#设置当前图片点两列
fig_close.plot(df.close)
plt.title(stock+'收盘价')
fig_low = plt.subplot2grid(fig_shap,(2,0))#没有设置大小将默认占一份空间
fig_low.plot(df.low)
plt.title(stock+'最低价')
fig_volume = plt.subplot2grid(fig_shap,(2,1))
fig_volume.plot(df.volume)
plt.title(stock+'成交额')
# fig.legend()
plt.show()