我在Ubuntu 17.10上使用Python 3.6。这是我试图为我的实际长代码做的MVC。
我必须制作两个信号卷积的动画图形,但是当我绘制图形时,屏幕变为灰色并且图形刚出现。
from tkinter import *
from tkinter import ttk
import matplotlib
matplotlib.use("TkAgg")
from matplotlib import style
style.use("ggplot")
from matplotlib import pyplot as plt
import matplotlib.animation as animation
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
from matplotlib.figure import Figure
import numpy as np
from scipy import signal as sn
import time
tim = np.arange(0,10)
tim1 = np.arange(0,10)
root = Tk()
root.geometry('1280x700')
root.resizable(width = False, height = False)
root.configure(bg = fondo)
root.title('Convolusión')
f2 = Figure(figsize=(3,2), dpi=100)
k2 = f2.add_subplot(1, 1, 1)
plot = FigureCanvasTkAgg(f2, root)
plot.show()
plot.get_tk_widget().place(x=50,y=470)
k3.clear()
ycc = sn.convolve(s1,s2,mode="full")
t = np.arange(min(tim)+min(tim1),max(tim)+max(tim1)+1)
i=0
tim = [0]*len(t)
y = [0]*len(t)
for x in t:
tim[i] = t[i]
y[i] = ycc[i]
k3.clear()
k3.plot(tim,y)
plot = FigureCanvasTkAgg(self.f3, self.root)
plot.show()
plot.get_tk_widget().place(x=450,y=470)
i=i+1
plt.pause(0.1)