Dear all
I ran into an issue with wxPython and matplotlib.pyplot. Please take a look at the attached code example. It runs fine as it is on my Linux machine. However, if I uncomment the plt.subplots_adjust(...) line, it hangs at exit.
Am I doing something wrong, or is this a bug? If it is a bug, is it in wxPython or in matplotlib?
wxPython version 4.0.7
matplotlib version 3.5.2
Debian SID
------------------------------------
from numpy import arange, sin, pi
import matplotlib
matplotlib.use('WXAgg')
import matplotlib.pyplot as plt
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
import wx
class CanvasPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.figure = Figure()
self.axes1 = self.figure.add_subplot(2,1,1)
self.axes2 = self.figure.add_subplot(2,1,2)
self.canvas = FigureCanvas(self, -1, self.figure)
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
self.SetSizer(self.sizer)
self.Fit()
### plt.subplots_adjust(hspace=0.4) # <-- This causes trouble!
def draw(self):
t = arange(0.0, 3.0, 0.01)
s = sin(2 * pi * t)
self.axes1.plot(t, s)
self.axes2.plot(t, -s)
if __name__ == "__main__":
app = wx.App()
fr = wx.Frame(None, title='test')
panel = CanvasPanel(fr)
panel.draw()
fr.Show()
app.MainLoop()
------------------------------------