- 论坛徽章:
- 0
|
这是两个函数,我想在plotline函数中调用了beforeplot函数。这里我写的语句是“a = self.BeforePlot(event)”,但是,我不能确定对错。程序运行后没有实现预期效果,还请大家帮我看看。
#ascertain the value of i determined by RadioButton
def BeforePlot(self,event):
radioSelected = event.GetEventObject()
if radioSelected.Label == "Elmo":
i = 2
elif radioSelected.Label == "Ernie":
i = 3
else:
i = 5
return i
#plot the line about profit
def PlotLine(self,event):
a = self.BeforePlot(event)
x_values = numpy.arange(0,math.pi*4,0.1)
y_values = [math.sin(a*x) for x in x_values]
pylab.plot(x_values,y_values)
pylab.xlabel('x values')
pylab.ylabel('sine of ax')
pylab.title('plot of profit')
pylab.grid(True)
pylab.show() |
|