class ChartDialog(wx.Dialog): def __init__(self, parent, id=-1, title=""): self.result = title.__getitem__('result') self.objectivenames = title.__getitem__('objectivenames') self.objectivenumber = len(self.objectivenames) self.variablenames = title.__getitem__('variablenames') self.variablenumber = len(self.variablenames) wx.Dialog.__init__(self, parent, id, title=u'结果', size=(400, 350), style=wx.DEFAULT_DIALOG_STYLE|wx.THICK_FRAME|wx.RESIZE_BORDER|wx.TAB_TRAVERSAL) self.xcb = wx.ComboBox(self, choices=self.objectivenames, style=wx.CB_READONLY) self.ycb = wx.ComboBox(self, choices=self.objectivenames, style=wx.CB_READONLY) drawButton = wx.Button(self, label=u'确定', id=wx.ID_ANY) quitButton = wx.Button(self, label=u'退出', id=wx.ID_CANCEL) xlabel = wx.StaticText(self, label=u'横坐标(x):') ylabel = wx.StaticText(self, label=u'纵坐标(y):') xBoxSizer = wx.BoxSizer(wx.HORIZONTAL) yBoxSizer = wx.BoxSizer(wx.HORIZONTAL) buttonSizer = wx.BoxSizer(wx.HORIZONTAL) xBoxSizer.Add(xlabel, 0, wx.ALL, 8) xBoxSizer.Add(self.xcb, 0, wx.ALL, 8) yBoxSizer.Add(ylabel, 0, wx.ALL, 8) yBoxSizer.Add(self.ycb, 0, wx.ALL, 8) buttonSizer.Add(drawButton, 0, wx.ALL, 8) buttonSizer.Add(quitButton, 0, wx.ALL, 8) MainSizer = wx.BoxSizer(wx.VERTICAL) MainSizer.Add(xBoxSizer, 0, wx.ALL, 8) MainSizer.Add(yBoxSizer, 0, wx.ALL, 8) MainSizer.Add(buttonSizer, 0,wx.ALL, 8) self.SetSizer(MainSizer) self.Bind(wx.EVT_BUTTON, self.drawAPP, drawButton) def drawAPP(self, e): self.app = PlotApp() try: xlabel = self.xcb.GetValue() xindex = self.objectivenames.index(xlabel) ylabel = self.ycb.GetValue() yindex = self.objectivenames.index(ylabel) except: wx.MessageBox(u'请先选择x,y数据', u'提示', wx.OK | wx.ICON_INFORMATION) x = [] y = [] for individual in self.result: x.append(individual[xindex]) y.append(individual[yindex]) self.app.plot(x, y, title=xlabel+' - '+ylabel, label=xlabel+' - '+ylabel, xlabel=xlabel, ylabel=ylabel) self.app.run()
def plot_graph(self, data): x = [i for i in range(0, len(data))] x_data = np.array(x) y_data = np.array(data) app = PlotApp() app.plot(x_data, y_data, title='Compound interest over term', label='Compound interest', ylabel='Funds (£)', xlabel='Time (Months)') app.write_message('Try Help->Quick Reference') app.run()
geo.Solve() print geo.Area() p = geo.Centroid() alfa = geo.tan_alfa() print p print "a=" + str(alfa) app = PlotApp() Path = DrawGeometry(Tsec) Path.Draw() #newIsec = Isec.moveCoor(-p[0], -p[1]) #origin = Point(0,0) #newIsec = Isec.rotate(pi/4, p) #newIsec = Isec.transform(-p[0],-p[1],-alfa, origin) #geo1 = GeoCalculator(newIsec) #geo1.Solve() #print geo1.Area() #print geo1.Centroid() for i in Path._paths: m,n=zip(*i) app.oplot(m,n,title='Example PlotApp', label='a', ylabel=r'$k^2\chi(k) $', xlabel=r'$ k \ (\AA^{-1}) $') app.write_message('Try Help->Quick Reference') app.run()
from wxmplot import PlotApp from numpy import arange, sin, cos, exp, pi xx = arange(0.0,12.0,0.1) y1 = 1*sin(2*pi*xx/3.0) y2 = 4*cos(2*pi*(xx-1)/5.0)/(6+xx) y3 = -pi + 2*(xx/10. + exp(-(xx-3)/5.0)) p = PlotApp() p.plot(xx, y1, color='blue', style='dashed', title='Example PlotApp', label='a', ylabel=r'$k^2\chi(k) $', xlabel=r'$ k \ (\AA^{-1}) $' ) p.oplot(xx, y2, marker='+', linewidth=0, label =r'$ x_1 $') p.oplot(xx, y3, style='solid', label ='x_2') p.write_message('Try Help->Quick Reference') p.run()