plt.subplot2grid用法详解

subplot2grid用法详解

#! /user/bin/env python
#_*_coding:utf-8 -*_
#__author__ = '株洲市易美智能工程有限责任公司'
#Email:[email protected]
import tushare as ts
import tkinter
import matplotlib.pyplot as plt
# from matplotlib.backends.backend_tkagg import(FigureCanvasTkAgg,NavigationToolbar2TK)
plt.rcParams['font.sans-serif'] = ['SimHei'] #用来显示中文
plt.rcParams['axes.unicode_minus'] = False #用来显示负号
df1 = ts.get_k_data('000001',ktype = 'D') #导入股票数据
print('df1',df1)
root = tkinter.Tk()
root.title = '在Tkinter里显示图像'
fig = plt.figure('000001',facecolor = 'yellow',figsize=(20,10))#定义一个名字为000001的图形,背景颜色为yellow,图片大小
行放大20倍,列放大10倍
ax1 = plt.subplot2grid((3,3),(0,0),colspan = 3)#图形分为3行3列,当前图在0行0列开始画,colspan为当前图占3列宽度
ax2 = plt.subplot2grid((3,3),(1,0),colspan = 2)#图形分为3行3列,当前图在1行0列开始画,colspan为当前图占2列宽度
ax3 = plt.subplot2grid((3,3),(1,2),rowspan = 2)#图形分为3行3列,当前图在1行2列开始画,rowspan为当前图占2行高度
ax4 = plt.subplot2grid((3,3),(2,0))#在没有行列宽度定义的情况下只占一个行和列的大小
ax5 = plt.subplot2grid((3,3),(2,1))#同上
plt.suptitle('在tkinker中显示matplotlib.pyplot 3*3的图形')
ax1.plot(df1.close)
ax2.plot(df1.open)
ax3.plot(df1.volume)
ax4.plot(df1.low)
ax5.plot(df1.high) 
# toolbar.update()
plt.show()
发布了9 篇原创文章 · 获赞 1 · 访问量 435

猜你喜欢

转载自blog.csdn.net/yinghu5312/article/details/104743744
今日推荐