Hi Josh,
I am not quite sure what information you need, but I have an application with several wx notebooks, each with pages carrying related but different 2D and 3D plots.  I hope this overview covers what you want.  In the code below I set up the axes and toolbar in each panel ready to accept plots as required.  I use wxFormbuilder to create MyFrame1 and then this code to add graphs and other functionality.  The 'tickle' function is called when a notebook is selected for display.

import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg
from matplotlib.figure import Figure
from mpl_toolkits.mplot3d import Axes3D

class ProjectFrame(bare_gui.MyFrame1):
    def __init__( self, parent):
        bare_gui.MyFrame1.__init__( self, parent)
        self.Create2DGraph(self.CT_graph_1, "Current / %")#CT notebook
        self.Create2DGraph(self.VT_graph_1, "Voltage/ %")#VT notebook

    def Create2DGraph(self, panel, xlabel):
        panel.figure = Figure(None)
        panel.canvas = FigureCanvas(panel, -1, panel.figure)
        panel.axes1 = panel.figure.add_subplot(2,1,1)
        panel.axes2 = panel.figure.add_subplot(2,1,2)
        panel.axes1.set_ylabel('Error / %')
        panel.axes2.set_ylabel('Phase / crad')
        panel.sizer = wx.BoxSizer(wx.VERTICAL)
        panel.sizer.Add(panel.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
    def add_2Dtoolbar(self, panel):
        panel.toolbar = NavigationToolbar2WxAgg(panel.canvas)
        tw, th = panel.toolbar.GetSizeTuple()
        fw, fh = panel.canvas.GetSizeTuple()
        panel.toolbar.SetSize(wx.Size(fw, th))
        panel.sizer.Add(panel.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar

    def Create3DGraph(self, panel):
        panel.figure = Figure(None)
        panel.canvas = FigureCanvas(panel, -1, panel.figure)
        panel.ax = Axes3D(panel.figure)
        #these labels should be selected later for specific components
        panel.ax.set_xlabel('Current / %')
        panel.ax.set_ylabel('Phase / degree')
        panel.ax.set_zlabel('Error / %')
        panel.sizer = wx.BoxSizer(wx.VERTICAL)
        panel.sizer.Add(panel.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)

From: Joshua Koehler [jjkoehler9@gmail.com]
Sent: Friday, 13 July 2012 10:45 p.m.
To: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] wxpython matplotlib figure resize

Hi Keith,

How are you storing the plot in the frame/panel?

On Jul 12, 2012, at 11:59 PM, Keith Jones wrote:

Hi Josh,
Yes I too am using the wx backend.




From: Tony Yu [mailto:tsyu80@gmail.com] 
Sent: Friday, 13 July 2012 3:16 p.m.
To: Keith Jones
Cc: Joshua Koehler; matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] wxpython matplotlib figure resize


On Thu, Jul 12, 2012 at 9:27 PM, Keith Jones <K.Jones@irl.cri.nz> wrote:
I am interested in a better solution to this problem, but I have used this simple method to force the right size.


    def tickle(self):
        #gets frame to redraw and resize, not elegant.
        if self.IsMaximized(): #then needs a kick
            x,y = self.GetSize()
            self.SetSize((x-1, y-1))
            self.SetSize((x, y))




From: Joshua Koehler [mailto:jjkoehler9@gmail.com] 
Sent: Saturday, 7 July 2012 1:51 a.m.
To: matplotlib-users@lists.sourceforge.net
Subject: [Matplotlib-users] wxpython matplotlib figure resize


Hi all,

I am currently trying to use matplotlib with wxPython and all is going well except for one annoying issue that I can't figure out. 

I initialize a wxcanvas object with a figure and then throughout the life of the program I want the canvas' figure to change and display the corresponding plot. I can get the change of figure, but when the program goes to plot, the figure isn't the right size. It changes to the right size only when I manually resize the figure (see attached images). Is there some command that I am missing? This is the update sequence I am using:

self.figure = figure
        self.canvas.figure = self.figure

As you can tell from the comments (there are more in my code), I have tried a variety of ways to update the figure off the bat.



This may be similar to a Qt-backend bug, which didn't take the toolbar into account when resizing the figure:
It doesn't quite fit, though, because Josh's original example shows a figure that's the correct size (but the axes doesn't fill the figure).  The toolbar issue tended to squish the axes in the vertical direction (at least in the GUI window), whereas Josh's example is squished in the horizontal direction.


Keith: Are you also using the Wx-backend? I don't have Wx installed so I can't provide much help. I've been planning to take a look at a similar issue in the Tk backend, but haven't had time.





This electronic transmission and any documents accompanying this electronic transmission contain confidential information belonging to the sender. This information may be legally privileged. The information is intended only for the use of the individual or entity named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or the taking of any action in reliance on or regarding the contents of this electronically transmitted information is strictly prohibited.