Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6211651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:22:35+00:00 2026-05-24T06:22:35+00:00

I’m trying to make matplotlib cooperate with wxPython, and my application listed below behaves

  • 0

I’m trying to make matplotlib cooperate with wxPython, and my application listed below behaves awkward: under Ubuntu it works as intended, but under Windows XP it seems to freeze, i.e. button does not react to clicking, and elements are overlapping(as if GridSizer didn’t work). What am I doing wrong?

Update: After changing GridSizer to BoxSizer everything works under both operating systems,
but problem with GridSizer is still not solved.

# wxPython module
import wx
# Matplotlib Figure object
from matplotlib.figure import Figure
# Numpy functions for image creation
import numpy as np

# import the WxAgg FigureCanvas object, that binds Figure to
# WxAgg backend. In this case, this is a wxPanel
from matplotlib.backends.backend_wxagg import \
FigureCanvasWxAgg as FigureCanvas

class MyFigurePanel(wx.Panel):
  """Class to represent a Matplotlib Figure as a wxFrame"""
  def __init__(self, parent):
    wx.Panel.__init__(self, parent)
    # usual Matplotlib functions
    self.figure = Figure()#figsize=(6, 4), dpi=100)
    self.axes = self.figure.add_subplot(111)
    x = np.arange(0, 6, .01)
    y = np.sin(x**2)*np.exp(-x)
    self.axes.plot(x, y)
    # initialize the FigureCanvas, mapping the figure to
    # the Wx backend
    self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)

class MyButtonPanel(wx.Panel):
  def __init__(self, parent):
    wx.Panel.__init__(self, parent)
    save_button = wx.Button(self, label = 'SAVE se')



class MyFrame(wx.Frame):
  def __init__(self):
    wx.Frame.__init__(self,None)
    panelx = wx.Panel(self)
    self.figure = MyFigurePanel(panelx)
    self.buttons = MyButtonPanel(panelx)
    grid = wx.GridSizer(1,2)
    grid.Add(self.figure)
    grid.Add(self.buttons)
    panelx.SetSizer(grid)


# Create a wrapper wxWidgets application     
app = wx.PySimpleApp()
# instantiate the Matplotlib wxFrame
frame = MyFrame()
# show it
frame.Show(True)
# start wxWidgets mainloop
app.MainLoop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T06:22:36+00:00Added an answer on May 24, 2026 at 6:22 am

    This works (after modifying MyFrame):

    from matplotlib.backends.backend_wxagg import \
    FigureCanvasWxAgg as FigureCanvas
    
    class MyFigurePanel(wx.Panel):
      """Class to represent a Matplotlib Figure as a wxFrame"""
      def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.figure = Figure()#figsize=(6, 4), dpi=100)
        self.axes = self.figure.add_subplot(111)
        x = np.arange(0, 6, .01)
        y = np.sin(x**2)*np.exp(-x)
        self.axes.plot(x, y)
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure) 
    
    class MyButtonPanel(wx.Panel):
      def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        button = wx.Button(self, label = 'SAVE se')
    
    class MyFrame(wx.Frame):
      def __init__(self):
        wx.Frame.__init__(self, None)
        self.figure = MyFigurePanel(self)
        self.buttons = MyButtonPanel(self)
        grid = wx.BoxSizer(wx.VERTICAL)
        grid.Add(self.buttons, flag=wx.EXPAND)
        grid.Add(self.figure, flag=wx.EXPAND)
        self.SetSizer(grid)
        self.Fit()
    
    
    # Create a wrapper wxWidgets application     
    app = wx.PySimpleApp()
    # instantiate the Matplotlib wxFrame
    frame = MyFrame()
    # show it
    frame.Show(True)
    # start wxWidgets mainloop
    app.MainLoop()
    

    The key change to make it run is the elimination of the panel in MyFrame. Actually you are already adding two panels.
    Also I use a wx.BoxSizer() for a better look (GridSizer produces cells of the same size)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.