1 from .PlotSelectionFrame
import PlotSelectionFrame
3 import matplotlib.backends.backend_wx
4 import matplotlib.backends.backend_wxagg
5 import matplotlib.figure
8 class CanvasFrame(wx.Frame):
10 Main window, containing the plotting canvas.
13 def __init__(self, plotter):
17 wx.Frame.__init__(self,
None, title=
'my title', size=(sizeX, sizeY))
27 self.
figure = matplotlib.figure.Figure(figsize=(sizeX / dpi, sizeY / dpi), dpi=dpi)
28 self.
canvas = matplotlib.backends.backend_wxagg.FigureCanvasWxAgg(self, wx.ID_ANY, self.
figure)
35 self.
plotOptions[
'sizer'] = wx.BoxSizer(wx.HORIZONTAL)
41 self.
plotOptions[
'checkBoxes'][
'logx'] = wx.CheckBox(self)
44 self.
plotOptions[
'sizer'].Add(wx.StaticText(self, label=
"log-x"), 0, wx.LEFT | wx.EXPAND)
46 self.
plotOptions[
'checkBoxes'][
'logy'] = wx.CheckBox(self)
49 self.
plotOptions[
'sizer'].Add(wx.StaticText(self, label=
"log-y"), 0, wx.LEFT | wx.EXPAND)
51 self.
plotOptions[
'checkBoxes'][
'dashedIfNegative'] = wx.CheckBox(self)
54 self.
plotOptions[
'sizer'].Add(wx.StaticText(self, label=
"dashed-if-negative"), 0, wx.LEFT | wx.EXPAND)
57 self.
toolbar = matplotlib.backends.backend_wx.NavigationToolbar2Wx(self.
canvas)
85 def updateCanvas(self):
88 def updateLegend(self):
91 handlesAndLegends = self.
axes.get_legend_handles_labels()
92 if len(handlesAndLegends[0]) != 0:
93 self.
legend = self.
axes.legend(loc=
'center left', bbox_to_anchor=(1, 0.5))
96 def onPlotOptionsCheckbox(self, event):
97 if event.GetId() == self.
plotOptions[
'checkBoxes'][
'logx'].GetId():
101 self.
plotter.setXScale(
'linear')
102 elif event.GetId() == self.
plotOptions[
'checkBoxes'][
'logy'].GetId():
103 if event.IsChecked():
106 self.
plotter.setYScale(
'linear')
107 elif event.GetId() == self.
plotOptions[
'checkBoxes'][
'dashedIfNegative'].GetId():
108 if event.IsChecked():
109 self.
plotter.setPlotDashedIfNegative(
True)
111 self.
plotter.setPlotDashedIfNegative(
False)
113 raise ValueError(
"Cannot handle event")
119 Sets the checkbox that signifies that the x-axis is logarithmic.
121 @param[in] value True to activate the checkbox, false to deactivate.
128 Sets the checkbox that signifies that the y-axis is logarithmic.
130 @param[in] value True to activate the checkbox, false to deactivate.
133 self.
plotOptions[
'checkBoxes'][
'logy'].SetValue(value)
137 Sets the checkbox that controls the plot-dashed-if-negative feature.
139 @param[in] value True to activate the checkbox, false to deactivate.
142 self.
plotOptions[
'checkBoxes'][
'dashedIfNegative'].SetValue(value)
144 def _updateStatusBar(self, event):
146 Updates the status bar after an event happened.
148 @param[in] event The event to react to.
152 x, y = event.xdata, event.ydata
153 self.
_statusBar.SetStatusText(
'x = ' + str(x) +
', y = ' + str(y))