Matplotlib Subplot with wxPython crashes exe but not when code run from console in IDE

Viewed 62

I updated my packages to matplotlib 3.3.3 and wxPython 4.1.1.

Before that my code worked fine directly from the IDE as well as an EXE.

I figured out that is has something to do with the add_subplot() function from matplotlib.

Also also found this discussion from github, which is kind of something else but nearly the same behaviour: Link

This is how i create my Plot:

import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas

class WeeklyOrderGraph(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.figure = self.matplotlib_figure = Figure()
        self.figure.patch.set_facecolor('#F0F0F0')
        
        print("Until here all fine")
        self.axes = self.figure.add_subplot(111) 
        print("Before this it crashes")
        
        self.canvas = FigureCanvas(self, 1, self.figure)  
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.EXPAND)         
        self.SetSizer(self.sizer)

This widget gets placed in a sizer here and there. Is there anyone who knows how to fix this? I would love to keep the new versions of these to packages!

The EXE crashed without any Error message! And the Ipython Console isn't showing anything.

Has anyone similar problems?

0 Answers
Related