当前位置:   article > 正文

python把四个图画在一个窗口_Python matplotlib如何在一个窗口画多张图,使用forward to next view按钮切换...

python 画四张图

展开全部

# -*- coding: utf-8 -*-

from matplotlib.figure import Figure

from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

from Tkinter import *

class test(object):

def __init__(self,parent):

self.parent = parent

self.n = 0

Button(self.parent,text = 'change',command = self.change).pack()

'''表格个数'''

num = 2

fig = []

self.canvas = []

for i in range(num):

fig.append(Figure())

self.canvas.append(FigureCanvasTkAgg(fig[i],master = self.parent))

self.canvas[0]._tkcanvas.pack()

'''以下可以创2113建不同的图5261'''

axe = fig[0].add_subplot(111)

axe.set_title(u'第一个图',{'fontname':'STSong'})

axe2 = fig[1].add_subplot(211)

axe2_2 = fig[1].add_subplot(212)

axe2.set_title(u'第二个图',{'fontname':'STSong'})

def change(self):

self.n +=1

if self.n == 2:

self.n = 0

self.canvas[self.n -1]._tkcanvas.pack_forget()

self.canvas[self.n]._tkcanvas.pack()

if __name__ == "__main__":

root = Tk()

test(root)

root.mainloop()

您看着样4102能不能满足您的要求1653?

resize,m_lfit,w_600,h_800,limit_1

单击change后:

resize,m_lfit,w_600,h_800,limit_1

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/612700
推荐阅读
相关标签
  

闽ICP备14008679号