refactor for easier multi-curve plotting

This commit is contained in:
2020-12-01 22:15:37 +01:00
parent b5e9b7a48c
commit 6f17db566c
2 changed files with 8 additions and 6 deletions
+2 -1
View File
@@ -433,7 +433,8 @@ class TweakPanel(wx.Panel):
xs = [datetime.strptime(x, date_fmt) for x in xs]
ys = [float(y) for y in ys]
dlg = PlotDialog("Tweak History", "step", xs, ys, ".-")
dlg = PlotDialog("Tweak History")
dlg.plot.step(xs, ys, ".-")
dlg.plot.figure.autofmt_xdate()
dlg.ShowModal()
dlg.Destroy()
+6 -5
View File
@@ -13,19 +13,16 @@ from .widgets import WX_DEFAULT_RESIZABLE_DIALOG_STYLE
class PlotDialog(wx.Dialog):
def __init__(self, title, method, *args, **kwargs):
def __init__(self, title):
wx.Dialog.__init__(self, None, title=title, style=WX_DEFAULT_RESIZABLE_DIALOG_STYLE)
self.plot = plot = PlotPanel(self)
method = getattr(plot, method)
method(*args, **kwargs)
plot.draw()
self.status_bar = status_bar = wx.StatusBar(self)
status_bar.SetFieldsCount(3) # toolbar help, x, y
self.Bind(wx.EVT_TOOL_ENTER, self.update_statusbar_help)
self.plot.canvas.mpl_connect("motion_notify_event", self.update_statusbar_coord)
plot.canvas.mpl_connect("motion_notify_event", self.update_statusbar_coord)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add(plot, proportion=1, flag=wx.ALL|wx.EXPAND, border=0)
@@ -34,6 +31,10 @@ class PlotDialog(wx.Dialog):
self.SetSizerAndFit(vbox)
def ShowModal(self):
self.plot.draw()
wx.Dialog.ShowModal(self)
def GetStatusBar(self):
return self.status_bar