- 論壇徽章:
- 0
|
這是兩個(gè)函數(shù),我想在plotline函數(shù)中調(diào)用了beforeplot函數(shù)。這里我寫(xiě)的語(yǔ)句是“a = self.BeforePlot(event)”,但是,我不能確定對(duì)錯(cuò)。程序運(yùn)行后沒(méi)有實(shí)現(xiàn)預(yù)期效果,還請(qǐng)大家?guī)臀铱纯础?br />
#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() |
|