Matplotlib 按钮内的matlibplot图形
我想知道为什么我的matlibplot当前在一个按钮内作图,如下所示: 代码如下所示Matplotlib 按钮内的matlibplot图形,matplotlib,Matplotlib,我想知道为什么我的matlibplot当前在一个按钮内作图,如下所示: 代码如下所示 from gui export Index import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import Button fig, ax = plt.subplots() plt.subplots_adjust(buttom-0.2) pos_trim = plt.axes([0.20, 0.05, .1,
from gui export Index
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
fig, ax = plt.subplots()
plt.subplots_adjust(buttom-0.2)
pos_trim = plt.axes([0.20, 0.05, .1, 0.075])
b_trim = Button(pos_trim, 'Trim', hoverclor='0.25')
callback = Index(c)
b_trim.on_clicked(callback.autoTrim) # from gui.index
freqs = np.arange(2,20,3)
t = np.arange(0.0, 1.0, 0.05)
s = np.sin(2*np.pi*freqs[0]*t)
l, = plt.plot(t,s,lw=2)
plt.show()
索引类:
class Index:
def __init__(self, chart):
self.__chart = chart
def autoTrim(self, event):
print "Autotrim"
#self.__chart.autoTrim()
plt.draw()
尝试更改将数据打印到的行:
l, = ax.plot(t,s,lw=2)
也就是说,打印到为打印创建的轴(ax
)。否则,将打印到创建的最后一个轴,在本例中,这是按钮