python - mplot3d in wxPython frame -
I am writing an application in wxPython. The button "plot" shows wxFrame with 3D surface, but I can not rotate the surface Is it possible that a 3D platform be placed in deflection? How can I
example:? Import matplotlib matplotlib.use ('WXAgg') from matplotlib.backends.backend_wx as FigureCanvas form matplotlib.backends.backend_wxagg Import ImageCanvasWxAgg Import from NavigationToolbar2Wx as plt class CanvasFrame (wx.Frame) mpl_toolkits .mplot3d import axes3d imports from matplotlib.pyplot wx: def __init __ (self): wx.Frame .__ init __ (self, none, -1, 'CanvasFrame', size = (550,350)) self.SetBackgroundColour (wx .NamedColor ( "white")) self.figure = plt.figure () self.axes = axes3d.Axes3D (self.figure) X, Y, Z = axes3d.get_test_data (0.05) Self .axes.plot_surface (x, y , Z, rstride = 8, cstride = 8, alpha = 0.3) CSET = self.axes.contour (X, Y, Z, zdir = 'z', offset = -100) CSET = Self.axes.contour (A C, y, z, zdir = 'x', offset = -40) cset = self.axes.contour (x, y, z, zdir = 'y', offset = 40) self.canvas = shape sheeting (self, 1, Swfigr) self.sizer = wx.boxSizer (wx.VERTICA L) self.sizer.Add (self.canvas, 1, wx.LEFT | Wx.TOP | wx.GROW) self.SetSizer (self.sizer) self.Fit () self.add_toolbar () def add_toolbar (self): self.toolbar = NavigationToolbar2Wx (self.canvas) self.toolbar.Realize () if wx.Platform = = '__WXMAC__': self.SetToolBar (self.toolbar ) and: tw, th = self.toolbar.GetSizeTuple () FW, FH = self.canvas.GetSizeTuple () self.toolbar.SetSize (wx.Size (FW, tH)) Self.sizer.Add (self. Toolbar, 0, wx.LEFT | WxkEXPAND) Selfktoolbarkupdate () def OnPaint (self, event): Selfkcanvaskdraw () class app (WxkApp): def OnInit (self): frame = Kanwasfrem () frame. Show (true) right back true app = app (0) app.MainLoop ()
You probably want to ask wxPython google group because I have seen people using matlab as well. Anyway, by looking at the matplotlib website, it appears that there is a wxMpl module that can help:
My guess is, if matplotlib can rotate the plot out of wx, then you can just Some events will have to pass through it to work within the wx to matlotlib wx.
Comments
Post a Comment