Search code examples
user-interfacelayoutmatplotlibgridwxpython

Combine plot and grid in WxPython GUI Example


Currently I'm developing a GUI in WxPython.

I have created a lineplot using matplotib and a gridview of the underlying data. However, as I run the program, the grid and the plot are loaded into separate windows. I'm looking for examples or tutorials on how to integrate different items into a single window. Does anyone know any good example or tutorials on this? I cannot find a clear example.

Thanks!


Solution

  • Here is an example code Embedding a matplotlib figure inside a WxPython panel

    Basically, to hold a matplotlib figure you can use FigureCanvasWxAgg which can be imported like:

    from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
    

    and, you will do the normal plotting on Figure instance of MPL.

    from matplotlib.figure import Figure
    

    and put this Figure on FigureCanvasWxAgg which can be placed on a panel together with your grid using sizer.