| Newsgroups |
gmane.comp.python.wxpython |
| Message-ID |
<[email protected]> |
------=_Part_1660_1817861790.1656263565133
Content-Type: multipart/alternative;
boundary="----=_Part_1661_2109224042.1656263565133"
------=_Part_1661_2109224042.1656263565133
Content-Type: text/plain; charset="UTF-8"
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()
------------------------------------
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/c2cb8664-bd10-4875-b5c3-cf2d5cda5dbfn%40googlegroups.com.
------=_Part_1661_2109224042.1656263565133
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div>Dear all</div><div><br></div><div>I ran into an issue with wxPython an=
d matplotlib.pyplot. Please take a look at the attached code example. It ru=
ns fine as it is on my Linux machine. However, if I uncomment the plt.subpl=
ots_adjust(...) line, it hangs at exit.</div><div><br></div><div>Am I doing=
something wrong, or is this a bug? If it is a bug, is it in wxPython or in=
matplotlib?</div><div><br></div><div>wxPython version 4.0.7</div><div>matp=
lotlib version 3.5.2</div><div>Debian SID<br></div><div><br></div><div>----=
--------------------------------</div><div>from numpy import arange, sin, p=
i<br>import matplotlib<br>matplotlib.use('WXAgg')<br><br>import matplotlib.=
pyplot as plt<br><br>from matplotlib.backends.backend_wxagg import FigureCa=
nvasWxAgg as FigureCanvas<br>from matplotlib.backends.backend_wx import Nav=
igationToolbar2Wx<br>from matplotlib.figure import Figure<br><br>import wx<=
br><br>class CanvasPanel(wx.Panel):<br> def __init__(self, par=
ent):<br> wx.Panel.__init__(self, parent)<br>&nb=
sp; self.figure =3D Figure()<br> &=
nbsp; self.axes1 =3D self.figure.add_subplot(2,1,1)<br> =
self.axes2 =3D self.figure.add_subplot(2,1,2)<br> &nbs=
p; self.canvas =3D FigureCanvas(self, -1, self.figure)<br> &nb=
sp; self.sizer =3D wx.BoxSizer(wx.VERTICAL)<br> =
self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)<br=
> self.SetSizer(self.sizer)<br> &nb=
sp; self.Fit()<br> <br> &nbs=
p; ### plt.subplots_adjust(hspace=3D0.4) # <-- This causes troubl=
e!<br> <br> def draw(self):<br>&nbs=
p; t =3D arange(0.0, 3.0, 0.01)<br>  =
; s =3D sin(2 * pi * t)<br> self.axes1.pl=
ot(t, s)<br> self.axes2.plot(t, -s)<br><br><br>i=
f __name__ =3D=3D "__main__":<br> app =3D wx.App()<br> &=
nbsp; fr =3D wx.Frame(None, title=3D'test')<br> panel =3D Canv=
asPanel(fr)<br> panel.draw()<br> fr.Show()<br>&nb=
sp; app.MainLoop()</div><div>------------------------------------</d=
iv>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;wxPython-users" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">wxpy=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/wxpython-users/c2cb8664-bd10-4875-b5c3-cf2d5cda5dbfn%40googlegro=
ups.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d=
/msgid/wxpython-users/c2cb8664-bd10-4875-b5c3-cf2d5cda5dbfn%40googlegroups.=
com</a>.<br />
------=_Part_1661_2109224042.1656263565133--
------=_Part_1660_1817861790.1656263565133--