Esempio n. 1
0
class Plot(wx.Panel):
    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        btn = wx.Button(self, -1, "Toggle curve")
        sizer.Add(btn, 0, wx.EXPAND)
        screenSize = wx.DisplaySize()
        screenWidth, screenHeight = screenSize
        text_panel = wx.lib.scrolledpanel.ScrolledPanel(self,
                                                        -1,
                                                        size=(screenWidth,
                                                              100),
                                                        style=wx.SIMPLE_BORDER)
        text_panel.SetupScrolling()
        text_sizer = wx.BoxSizer(wx.VERTICAL)
        text_panel.SetSizer(text_sizer)

        def when_clicked(ev):
            print(ev)
            text_sizer.Add(wx.StaticText(text_panel, label="coucou"), 0)
            self.Layout()

        btn.Bind(wx.EVT_BUTTON, when_clicked)
        sizer.Add(text_panel, 1, wx.LEFT | wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)
Esempio n. 2
0
class Plot(wx.Panel):
    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        self.timeslider = wx.Slider(self,
                                    value=100,
                                    minValue=0,
                                    maxValue=100,
                                    name='time')
        self.zoomslider = wx.Slider(self,
                                    value=50,
                                    minValue=2,
                                    maxValue=50,
                                    name='zoom')

        self.timeslider.Bind(wx.EVT_SLIDER, self.OnSliderScrolltime)
        self.zoomslider.Bind(wx.EVT_SLIDER, self.OnSliderScrollzoom)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 5, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        sizer.Add(self.timeslider, 0, wx.EXPAND)
        sizer.Add(self.zoomslider, 0, wx.EXPAND)
        self.SetSizer(sizer)

    def OnSliderScrolltime(self, event):
        pass

    def OnSliderScrollzoom(self, event):
        pass
class PlotNotebook(wx.Panel):
    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(4, 10))
        self.canvas = FigureCanvas(self, 1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        self.ax1 = self.figure.add_subplot(1,2,1)
        self.ax2 = self.figure.add_subplot(1,2,2)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.toolbar, 1, wx.LEFT | wx.EXPAND, 5)
        sizer.Add(self.canvas, 1, wx.ALL | wx.EXPAND, 5)
        self.SetSizer(sizer)
        self.Fit()

    def draw_image(self, y, labels):
        self.ax1.clear()
        self.ax2.clear()
        self.figure.set_canvas(self.canvas)
        self.ax1.pie(y, labels = labels, labeldistance=0.3,autopct='%1.1f%%')
        x = numpy.arange(len(y))
        self.ax2.bar(x, y, tick_label=labels, alpha=0.5, width=0.4)
        self.canvas.draw()
    
    def savefig(self, *args, **kwargs):
        self.figure.savefig(*args, **kwargs)
Esempio n. 4
0
    def init_plot_panel(self):
        """Initializes the main panel of the AuxiliaryPage."""

        # Instantiate a figure object that will contain our plots.
        self.figure = Figure()

        # Initialize the figure canvas, mapping the figure object to the plot
        # engine backend.
        canvas = FigureCanvas(self.pan1, wx.ID_ANY, self.figure)

        # Wx-Pylab magic ...
        # Make our canvas the active figure manager for pylab so that when
        # pylab plotting statements are executed they will operate on our
        # canvas and not create a new frame and canvas for display purposes.
        # This technique allows this application to execute code that uses
        # pylab stataments to generate plots and embed these plots in our
        # application window(s).
        self.fm = FigureManagerBase(canvas, self.fignum)
        _pylab_helpers.Gcf.set_active(self.fm)

        # Instantiate the matplotlib navigation toolbar and explicitly show it.
        mpl_toolbar = Toolbar(canvas)
        mpl_toolbar.Realize()

        # Create a vertical box sizer to manage the widgets in the main panel.
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(canvas,
                  1,
                  wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT,
                  border=10)
        sizer.Add(mpl_toolbar, 0, wx.EXPAND | wx.ALL, border=10)

        # Associate the sizer with its container.
        self.pan1.SetSizer(sizer)
        sizer.Fit(self.pan1)
class CanvasFrame(wx.Frame):
    def __init__(self):
        super().__init__(None, -1, 'CanvasFrame', size=(550, 350))

        self.figure = Figure()
        self.axes = self.figure.add_subplot()
        t = np.arange(0.0, 3.0, 0.01)
        s = np.sin(2 * np.pi * t)

        self.axes.plot(t, s)
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  # comment this out for no toolbar

    def add_toolbar(self):
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        # By adding toolbar in sizer, we are able to put it at the bottom
        # of the frame - so appearance is closer to GTK version.
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()
Esempio n. 6
0
    def __init__(self, parent, theValues, theName, theColor="Blue"):
        wx.Panel.__init__(self, parent, style=wx.BORDER_SIMPLE)
        self.colors = colors.btViewColors
        self.listChoiceRun = ["   try  1   "]

        self.listRefRun = ["ref try 1"]
        self.listDifRun = ["diff try"]
        self.dicDifRun = {}
        self.theName = theName
        self.theColor = theColor
        self.theValues = []
        self.theValues.append(theValues)
        self.fig = Figure()
        self.nbRun = 1

        self.canvas = FigureCanvas(self, -1, self.fig)
        self.sizer = wx.BoxSizer(wx.VERTICAL)

        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.GROW, 1)

        tlb = ToolBar(self.canvas)
        self.sizer.Add(tlb, 0, wx.GROW)
        tlb.Realize()
        self.SetSizer(self.sizer)
        self.Fit()
        self.OnPlot(self.theValues, 0)
Esempio n. 7
0
class Radar_FFT_Plot(wx.Panel):
    def __init__(self, parent, *args, **kwargs):
        wx.Panel.__init__(self, parent, *args, **kwargs)
        self.SetBackgroundColour(BACKGROUND_COLOR)
        self.figure = Figure()
        self.canvas = FigureCanvas(self, 1, self.figure)
        self.range_fft_subplot = self.figure.add_subplot(111)
        self.range_fft_subplot.set_title('Range_FFT')
        self.range_fft_subplot.set_ylim([-5, 3])
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        #this seems hacky but it is the only way to start the prot
        self.range_fft_subplot_handle = None

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.EXPAND)
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(self.sizer)
        pub.subscribe(self.update_view, "update_radar_table")

    def update_view(self, msg):
        radar_msg = Radar_Message(msg)
        if radar_msg:
            range_fft = radar_msg.range_fft
            target_range_idx = radar_msg.target_range_idx
            self.update_range_fft_plot(range_fft, target_range_idx)

    def update_range_fft_plot(self, range_fft, target_range_idx):
        x = range(len(range_fft) / 4)
        #print(target_range_idx)
        #if self.range_fft_subplot_handle == None:
        self.range_fft_subplot.cla()
        self.range_fft_subplot.set_title('Range by FFT (psd dBm)')

        #range_fft_power = 20.0 * np.log10(range_fft[0:len(x)])
        Fs = 150.0e6
        N = 1024.0
        psdx = np.absolute(range_fft)**2 / (Fs * N)
        psdx = 2 * psdx
        freq = range(0, int(Fs / 8), int(Fs / len(x) / 8))
        psdx_dbm = 10 * np.log10(psdx) - 30  #30 is db to dbm
        #fft_power_max = max(psdx_db)
        #fft_power_min = min(psdx_db)
        self.range_fft_subplot.set_ylim([-110, -40])
        self.range_fft_subplot_handle = self.range_fft_subplot.plot(
            freq[0:len(x)], psdx_dbm[0:len(x)])[0]
        #print target_range_idx
        peaks = target_range_idx * Fs / len(x) / 8
        self.range_fft_peaks_handle = self.range_fft_subplot.scatter(
            peaks, psdx_dbm[target_range_idx], color='red')
        #self.range_fft_subplot_handle.set_xdata(x)
        #self.range_fft_subplot_handle.set_ydata(np.log10(range_fft[0:len(x)]))
        #self.range_fft_subplot.scatter(target_range_idx, np.log10(range_fft[target_range_idx]))
        #self.range_fft_peaks_handle.set_xdata(target_range_idx)
        #self.range_fft_peaks_handle.set_ydata(np.log10(range_fft[target_range_idx]))
        self.figure.canvas.draw()
Esempio n. 8
0
class Panel_Plot(wx.Panel):
    def __init__(self,
                 parent=None,
                 id=-1,
                 dpi=None,
                 figsize=(3, 2),
                 tbar=0,
                 row=1,
                 col=1,
                 fplots=None):  #, **kwargs):
        wx.Panel.__init__(self, parent=parent, id=id)
        self.parent = parent
        self.row = row
        self.col = col
        self.plt = fplots

        self.fig = mpl.figure.Figure(dpi=dpi, figsize=figsize)
        self.cvs = FigureCanvas(self, -1, self.fig)
        # ~ for plt pyplot
        # ~ self.fig, self.axs = plt.subplots(row, col)
        # ~ for mpl.Figure
        self.axs = self.fig.subplots(row, col)  #, sharex=True)
        self.fig.subplots_adjust(top=1.0,
                                 bottom=0.1,
                                 left=0.12,
                                 right=0.8,
                                 hspace=0.3,
                                 wspace=0.2)
        # ~ # Adjust the scaling factor to fit your legend text completely outside the plot
        # ~ # (smaller value results in more space being made for the legend)

        self._sizer = wx.BoxSizer(wx.VERTICAL)  # HORIZONTAL (bad!)
        self._sizer.Add(self.cvs, 1, wx.EXPAND)
        if tbar:
            self.toolbar = NavigationToolbar(self.cvs)
            self.toolbar.Realize()
            self._sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(self._sizer)

        self.sizer_ = wx.BoxSizer(wx.VERTICAL)
        self.sizer_.Add(self, -1, wx.ALL | wx.EXPAND, 5)
        self.parent.SetSizer(self.sizer_)

    def plot(self):
        axs = np.asarray(self.axs)
        for fplot, axs in zip(self.plt, axs.flat):
            fplot(axs)
        self.draw()

    def draw(self):
        # ~ self.fig.tight_layout()
        # ~ self.fig.canvas.draw()
        # ~ self.fig.canvas.flush_events()
        self.cvs.draw()
class PlotPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        self.fig = Figure((5, 4), 75)
        self.canvas = FigureCanvas(self, -1, self.fig)
        self.toolbar = NavigationToolbar(self.canvas)  # matplotlib toolbar
        self.toolbar.Realize()
        # self.toolbar.set_active([0,1])

        # Now put all into a sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        # This way of adding to sizer allows resizing
        sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        # Best to allow the toolbar to resize!
        sizer.Add(self.toolbar, 0, wx.GROW)
        self.SetSizer(sizer)
        self.Fit()

    def init_plot_data(self):
        a = self.fig.add_subplot(111)

        x = np.arange(120.0) * 2 * np.pi / 60.0
        y = np.arange(100.0) * 2 * np.pi / 50.0
        self.x, self.y = np.meshgrid(x, y)
        z = np.sin(self.x) + np.cos(self.y)
        self.im = a.imshow(z, cmap=cm.RdBu)  # , interpolation='nearest')

        zmax = np.max(z) - ERR_TOL
        ymax_i, xmax_i = np.nonzero(z >= zmax)
        if self.im.origin == 'upper':
            ymax_i = z.shape[0] - ymax_i
        self.lines = a.plot(xmax_i, ymax_i, 'ko')

        self.toolbar.update()  # Not sure why this is needed - ADS

    def GetToolBar(self):
        # You will need to override GetToolBar if you are using an
        # unmanaged toolbar in your frame
        return self.toolbar

    def OnWhiz(self, evt):
        self.x += np.pi / 15
        self.y += np.pi / 20
        z = np.sin(self.x) + np.cos(self.y)
        self.im.set_array(z)

        zmax = np.max(z) - ERR_TOL
        ymax_i, xmax_i = np.nonzero(z >= zmax)
        if self.im.origin == 'upper':
            ymax_i = z.shape[0] - ymax_i
        self.lines[0].set_data(xmax_i, ymax_i)

        self.canvas.draw()
Esempio n. 10
0
class Plot(wx.Panel):
    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)
Esempio n. 11
0
    def init_plot_panel(self):
        """Initializes the plotting panel of the SimulationPage."""

        INTRO_TEXT = "Phase Reconstruction and Inversion Using Simulated Data:"

        # Instantiate a figure object that will contain our plots.
        figure = Figure()

        # Initialize the figure canvas, mapping the figure object to the plot
        # engine backend.
        canvas = FigureCanvas(self.pan2, wx.ID_ANY, figure)

        # Wx-Pylab magic ...
        # Make our canvas the active figure manager for pylab so that when
        # pylab plotting statements are executed they will operate on our
        # canvas and not create a new frame and canvas for display purposes.
        # This technique allows this application to execute code that uses
        # pylab stataments to generate plots and embed these plots in our
        # application window(s).
        self.fm = FigureManagerBase(canvas, self.fignum)
        _pylab_helpers.Gcf.set_active(self.fm)

        # Instantiate the matplotlib navigation toolbar and explicitly show it.
        mpl_toolbar = Toolbar(canvas)
        mpl_toolbar.Realize()

        # Display a title above the plots.
        self.pan2_intro_text = INTRO_TEXT
        self.pan2_intro = wx.StaticText(self.pan2, wx.ID_ANY, label=INTRO_TEXT)
        font = self.pan2_intro.GetFont()
        font.SetPointSize(font.GetPointSize() + 1)
        font.SetWeight(wx.BOLD)
        self.pan2_intro.SetFont(font)

        # Create a progress bar to be displayed during a lengthy computation.
        self.pan2_gauge = WorkInProgress(self.pan2)
        self.pan2_gauge.Show(False)

        # Create a horizontal box sizer to hold the title and progress bar.
        hbox1_sizer = wx.BoxSizer(wx.HORIZONTAL)
        hbox1_sizer.Add(self.pan2_intro, 0, wx.ALIGN_CENTER_VERTICAL)
        hbox1_sizer.Add((10, 25), 1)  # stretchable whitespace
        hbox1_sizer.Add(self.pan2_gauge, 0)

        # Create a vertical box sizer to manage the widgets in the main panel.
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(hbox1_sizer, 0, wx.EXPAND|wx.ALL, border=10)
        sizer.Add(canvas, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, border=10)
        sizer.Add(mpl_toolbar, 0, wx.EXPAND|wx.ALL, border=10)

        # Associate the sizer with its container.
        self.pan2.SetSizer(sizer)
        sizer.Fit(self.pan2)
Esempio n. 12
0
class Plot(wx.Panel):
    def __init__(self, parent, id=-1, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = plt.Figure(figsize=(8, 6), tight_layout=True)
        self.ax = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)
Esempio n. 13
0
    class Plot(wx.Panel):
        def __init__(self, parent, fig, id=-1, dpi=None, **kwargs):
            wx.Panel.__init__(self, parent, id=id, **kwargs)
            fig.set_figheight(2)
            fig.set_figwidth(2)
            self.canvas = Canvas(self, -1, fig)
            self.toolbar = Toolbar(self.canvas)
            self.toolbar.Realize()

            sizer = wx.BoxSizer(wx.VERTICAL)
            sizer.Add(self.canvas, 1, wx.EXPAND)
            sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
            self.SetSizer(sizer)
Esempio n. 14
0
class Plots_Panel(wx.Panel):
    """

    Panel to hold matplotlib figure. There are three plots inside a grid, big one
    for temperature vs. deformation and smaller ones for time vs. deformation and
    time vs. temperature.

    """

    #--------------------------------------------------------------------------#
    def __init__(self, parent):

        wx.Panel.__init__(self, parent)

        self.init_plots()  #make figure
        self.PlotsCanvas = FigCanvas(self, wx.ID_ANY, self.fig)

        self.toolbar = NavigationToolbar(self.PlotsCanvas)
        self.toolbar.Realize()

        #correct toolbar size
        tw, th = self.toolbar.GetSizeTuple()
        fw, fh = self.PlotsCanvas.GetSizeTuple()

        # Sizers
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.PlotsCanvas, 1, wx.EXPAND | wx.GROW)
        sizer.Add(self.toolbar, 0, wx.BOTTOM | wx.GROW)
        self.toolbar.SetSize(wx.Size(fw, th))
        self.toolbar.update()
        self.SetSizerAndFit(sizer)

    #--------------------------------------------------------------------------#
    def init_plots(self):

        self.fig = Figure((-1, 7.5))
        self.fig.subplots_adjust(left=0.05, wspace=.3,
                                 hspace=3)  #sub plot spacing

        gs = matplotlib.gridspec.GridSpec(8, 3)
        self.ax1 = self.fig.add_subplot(gs[:, 0:2])
        self.ax2 = self.fig.add_subplot(gs[0:4, 2])
        self.ax3 = self.fig.add_subplot(gs[4:8, 2])

        self.ax1.set_xlabel(u'Temperatura ($^\circ$C)')
        self.ax1.set_ylabel(u'Deformación (mm)')
        self.ax2.set_xlabel(u'Tiempo (s)')
        self.ax2.set_ylabel(u'Deformación (mm)')
        self.ax3.set_xlabel(u'Tiempo (s)')
        self.ax3.set_ylabel(u'Temperatura ($^\circ$C)')
Esempio n. 15
0
class Plot_Panel(wx.Panel):
    def __init__(self, parent, id=-1, dpi=None, name='name', **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        # sizer = wx.BoxSizer(wx.VERTICAL)
        Sizer_checkbox = wx.StaticBox(self, -1, name)
        nmSizer = wx.StaticBoxSizer(Sizer_checkbox, wx.VERTICAL)
        nmSizer.Add(self.canvas, 1, wx.EXPAND | wx.EXPAND)
        nmSizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(nmSizer)
Esempio n. 16
0
    def __init__(self, parent, theValues, theName):
        wx.Panel.__init__(self, parent, style=wx.BORDER_SIMPLE)
        self.colors = colors.pcViewColors
        self.listChoiceRun = ["   run  1   "]

        self.listRefRun = ["ref run 1"]
        self.listDifRun = ["diff run"]
        self.dicDifRun = {}
        self.theName = theName
        self.theValues = []
        self.theValues.append(theValues)
        self.fig = Figure()
        self.nbRun = 1

        self.canvas = FigureCanvas(self, -1, self.fig)
        self.canvas.mpl_connect('motion_notify_event', self.onMouseMotion)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        horSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.cbChoiceRun = wx.ComboBox(self,
                                       choices=self.listChoiceRun,
                                       size=(180, 26))
        self.cbChoiceRun.SetValue(self.listChoiceRun[0])
        self.cbRefRun = wx.ComboBox(self,
                                    choices=self.listRefRun,
                                    size=(180, 26))
        self.cbRefRun.SetValue(self.listRefRun[0])
        self.cbDifRun = wx.ComboBox(self,
                                    choices=self.listDifRun,
                                    size=(180, 26))
        self.cbDifRun.SetValue(self.listDifRun[0])
        self.cbChoiceRun.Bind(wx.EVT_COMBOBOX, self.OnChoiceRun)
        self.cbRefRun.Bind(wx.EVT_COMBOBOX, self.OnRefRun)
        self.cbDifRun.Bind(wx.EVT_COMBOBOX, self.OnDifRun)
        horSizer.Add(self.cbChoiceRun)
        horSizer.Add(self.cbRefRun)
        horSizer.Add(self.cbDifRun)
        self.sizer.Add(horSizer)

        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.GROW, 1)

        tlb = ToolBar(self.canvas)
        self.sizer.Add(tlb, 0, wx.GROW)
        tlb.Realize()
        self.SetSizer(self.sizer)

        self.text = wx.StaticText(self, -1, label="")
        self.sizer.Add(self.text)
        self.Fit()
        self.OnPlot(self.theValues, 0)
Esempio n. 17
0
class Plot(wx.Panel):
    'Creates a plotting window'

    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(
            dpi=dpi,  #figsize=(5,7)
        )
        self.canvas = Canvas(self, -1, self.figure)
        self.toolbar = Toolbar(self.canvas)
        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)
Esempio n. 18
0
class Plot(wx.Panel):
    def __init__(self, parent, id=wx.ID_ANY, dpi = 100, experiment=None, **kwargs):
        wx.Panel.__init__(self, parent, id)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(10, 5))
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        # Bindings
        self.Bind(wx.EVT_BUTTON, self.OnPlot)
        self.canvas.mpl_connect('button_press_event', self.OnClick)

        # Layouts
        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)

    def OnPlot(self, event):
        """
        Pass the canvas to a possibly empyt list of experiments to plot themselves
        :param event:
        :return:
        """
        gatherer = self.GetTopLevelParent().gatherer
        experiment_list = gatherer.to_tuple()
        if experiment_list is None:
            with wx.MessageDialog(self, 'Please select an fpi experiment before plotting', 'No experiment(s) provided',
                                  wx.OK | wx.ICON_ERROR) as dlg:
                dlg.ShowModal()
            return
        else:
            ax = self.figure.gca()
            [gatherer.get_experiment(exp).plot(ax) for exp in experiment_list]
            self.canvas.draw()

    def plot(self, plot_type = None, experiment_list = None, choice = None):
        gatherer = self.GetTopLevelParent().gatherer
        experiment_data = [gatherer.get_experiment(exp.name) for exp in experiment_list]
        plotter = FPIPlotter(self.figure, experiment_data)
        plotter.plot(plot_type, choice)

        self.canvas.draw()

    def OnClick(self, event):
        pass
Esempio n. 19
0
class Plot(wx.Panel):
    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(32, 32))
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)

        self.theplot = self.figure.add_subplot(111)
        self.theplot.set_title("")
        self.theplot.set_xlabel("Frequency (MHz)")
        self.theplot.set_ylabel("SWR")
Esempio n. 20
0
class GrafikRWSW(wx.Panel):
    import wx
    import matplotlib as mpl
    from matplotlib.backends.backend_wxagg import (FigureCanvasWxAgg as
                                                   FigureCanvas,
                                                   NavigationToolbar2WxAgg as
                                                   NavigationToolbar)
    import numpy as np
    import matplotlib.pyplot as plt

    def __init__(self, parent, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)
        self.parent = parent
        from matplotlib.backends.backend_wx import _load_bitmap

        import pathlib

        self.figure = mpl.figure.Figure(dpi=None, figsize=(2, 2))
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.axes = self.figure.add_subplot(111)
        """disini untuk menentukan nilai sumbu x dan sumbu y"""
        self.x = [1, 2, 3, 4, 5, 6]
        self.y = [1, 2, 3, 4, 5, 6]

        self.axes.plot(self.x, self.y)

        self.toolbar = NavigationToolbar(self.canvas)
        self.pathimage = pathlib.Path.cwd() / "resources/images/binadata.png"
        self.newpathimage = pathlib.Path.cwd() / "resources/images/bila.png"
        self.ON_CUSTOM = wx.NewIdRef()
        self.image1 = wx.Image(str(self.pathimage))
        self.re_image3 = self.image1.Rescale(20, 20)
        self.re_image3.SaveFile(self.newpathimage.as_posix())
        self.newpathimage

        print(self.re_image3)
        self.toolbar.AddSimpleTool(self.ON_CUSTOM, _load_bitmap(self.newpathimage),\
                           'Pan to the left', 'Pan graph to the left')

        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)
Esempio n. 21
0
class MtlCanvas(wx.Window):
    def __init__(self, parent, size=(80, 80)):
        wx.Window.__init__(self, parent, size=size)
        self.figure = mpl.figure.Figure(figsize=(5, 2))
        self.ax = self.figure.gca()
        self.ax.set_facecolor(BG_COLOR)

        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)

    def add_conductor(self, conductor):
        if type(conductor) == Wire:
            x, y, r = conductor.x, conductor.y, conductor.radius
            shapes = [mpl.patches.Circle([x, y], r, color=RGB_CU, fill=True)]
        elif type(conductor) == Plane:
            w, t = conductor.width, conductor.thickness
            shapes = [
                mpl.patches.Rectangle([-0.5 * w, -t],
                                      w,
                                      t,
                                      color=RGB_CU,
                                      fill=True)
            ]
        elif type(conductor) == Shield:
            r, t = conductor.radius, conductor.thickness
            shapes = [
                mpl.patches.Circle([0, 0], r + t, color=RGB_CU, fill=True),
                mpl.patches.Circle([0, 0], r, color=BG_COLOR, fill=True)
            ]
        for shape in shapes:
            self.ax.add_patch(shape)
        self.ax.autoscale_view()
        self.ax.set_aspect(1)

    def clear_shapes(self):
        self.ax.cla()

    def redraw(self):
        self.figure.canvas.draw()
Esempio n. 22
0
class PlotPanel(wx.Panel):
    def __init__(self, *args, **kwargs):
        wx.Panel.__init__(self, *args, **kwargs)

        self.fig = Figure((0, 0), 70)
        self.ax = self.fig.add_subplot(111)
        self.canvas = FigureCanvas(self, -1, self.fig)
        self.toolbar = NavigationToolbar(self.canvas)  # matplotlib toolbar
        self.toolbar.Realize()
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        sizer.Add(self.toolbar, 0, wx.GROW)
        self.SetSizer(sizer)

    def plot(self, *args, **kwargs):
        self.ax.cla()
        self.ax.plot(*args, **kwargs)
        self.canvas.draw()
Esempio n. 23
0
    def __init__(self, parent, theValues, theName):
        wx.Panel.__init__(self, parent, style=wx.BORDER_SIMPLE)
        self.theName = theName
        self.theValues = theValues
        self.fig = Figure()

        self.canvas = FigureCanvas(self, -1, self.fig)
        self.canvas.mpl_connect('motion_notify_event', self.onMouseMotion)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        tlb = ToolBar(self.canvas)
        tlb.Realize()
        self.sizer.Add(tlb, 0, wx.GROW)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW, 1)
        self.SetSizer(self.sizer)

        self.text = wx.StaticText(self, -1, label="")
        self.sizer.Add(self.text)
        self.Fit()
Esempio n. 24
0
    def __init__(self, *args, **kw):
        wx.Panel.__init__(self, *args, **kw)

        # Can specify name on
        if 'title' in kw:
            self.title = kw['title']

        # Instantiate a figure object that will contain our plots.
        figure = Figure(figsize=(1, 1), dpi=72)

        # Initialize the figure canvas, mapping the figure object to the plot
        # engine backend.
        canvas = FigureCanvas(self, wx.ID_ANY, figure)

        # Wx-Pylab magic ...
        # Make our canvas an active figure manager for pylab so that when
        # pylab plotting statements are executed they will operate on our
        # canvas and not create a new frame and canvas for display purposes.
        # This technique allows this application to execute code that uses
        # pylab stataments to generate plots and embed these plots in our
        # application window(s).  Use _activate_figure() to set.
        self.pylab_interface = EmbeddedPylab(canvas)

        # Instantiate the matplotlib navigation toolbar and explicitly show it.
        mpl_toolbar = Toolbar(canvas)
        mpl_toolbar.Realize()

        # Create a vertical box sizer to manage the widgets in the main panel.
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(canvas, 1, wx.EXPAND | wx.LEFT | wx.RIGHT, border=0)
        sizer.Add(mpl_toolbar, 0, wx.EXPAND | wx.ALL, border=0)

        # Associate the sizer with its container.
        self.SetSizer(sizer)
        sizer.Fit(self)

        self._calculating = False
        self._need_plot = self._need_newmodel = False
        self.Bind(wx.EVT_SHOW, self.OnShow)
        self.plot_state = None
        self.model = None
        '''
Esempio n. 25
0
    def __init__(self,
                 parent,
                 theValues,
                 level,
                 pression,
                 theName,
                 nbpc,
                 axeXLegend="",
                 inPressure=True,
                 startPC=0):
        wx.Panel.__init__(self, parent, style=wx.BORDER_SIMPLE)
        self.colors = colors.kpcviewColors
        self.linestyles = colors.kpcviewLinestyles
        self.linewidths = colors.kpcviewLinewidths
        self.yInPressure = inPressure
        self.theName = theName
        self.theValues = theValues
        self.pression = pression
        self.level = level
        self.fig = Figure()
        self.nbpc = nbpc  # number of pc to draw

        self.sizer = wx.BoxSizer(wx.VERTICAL)

        self.SetSizer(self.sizer)

        self.axeXLegend = axeXLegend

        self.canvas = FigureCanvas(self, -1, self.fig)
        self.canvas.mpl_connect('motion_notify_event', self.onMouseMotion)
        tlb = ToolBar(self.canvas)
        tlb.Realize()

        self.sizer.Add(tlb, 0, wx.GROW)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW, 1,
                       wx.EXPAND)

        self.text = wx.StaticText(self, -1, label="")
        self.sizer.Add(self.text)

        self.Fit()
        self.OnPlot(theValues, startPC)
Esempio n. 26
0
class Plot(wx.Panel):
  """
  :mod:`matplotlib` plot

  Based on https://matplotlib.org/3.2.1/gallery/user_interfaces/embedding_in_wx5_sgskip.html.
  """

  def __init__(self, parent, id=-1, dpi=None, interactive=True, **kwargs):
    wx.Panel.__init__(self, parent, id=id, **kwargs)
    self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
    self.canvas = FigureCanvas(self, -1, self.figure)
    if interactive:
      self.toolbar = NavigationToolbar(self.canvas)
      self.toolbar.Realize()

    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(self.canvas, 1, wx.EXPAND)
    if interactive:
      sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
    self.SetSizer(sizer)
Esempio n. 27
0
class Plot(wx.Panel):
    """Creates a new page in the notebook to plot on."""
    def __init__(self, parent, id=-1, dpi=None, **kwargs):
        locale = wx.Locale(wx.LANGUAGE_ENGLISH)
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)

        #configure to make the graph cover full screen
        self.figure.subplots_adjust(left=0.03,
                                    right=0.95,
                                    top=0.94,
                                    bottom=0.1)
class Plot(wx.Panel):
    def __init__(self, parent, number, id=-1, dpi=None,**kwargs):
        wx.Panel.__init__(self, parent,  id=id,**kwargs)
        Plot.figure,Plot.axes = plt.subplots(dpi=dpi, figsize=(2, 2))
        plt.subplot(1,2,1)
        
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.EXPAND)
        sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)
        
        
    def onselect(self,eclick, erelease):
        global coordinate_new
        print('startposition: (%f, %f)' % (eclick.xdata, eclick.ydata))
        print('endposition  : (%f, %f)' % (erelease.xdata, erelease.ydata))
        print('used button  : ', eclick.button)
        coordinate_new=toggle_selector.RS.geometry
        coordinate_new=coordinate_new.astype(int)
        print(coordinate_new)
    
    

    def toggle_selector(self,event):
        global coorinate_new
        print('Key pressed.')
        if event.key in ['Q', 'q'] and toggle_selector.RS.active:
            print('RectangleSelector deactivated.')
            toggle_selector.RS.set_active(False)
        if event.key in ['A', 'a'] and not toggle_selector.RS.active:
            print('RectangleSelector activated.')
            toggle_selector.RS.set_active(True)
        if event.key in ['D', 'd'] and toggle_selector.RS.active:
            save_image(coordinate_new)
            
        rectprops = dict(facecolor='red', edgecolor = 'black',
                     alpha=0.2, fill=True)
Esempio n. 29
0
class DataDisplayPanel(wx.Panel):
    """
    This is currently the big panel in the middle of the application.

    This panel is the area used to visually display (probably via matplotlib)
    the results of whatever operation needs the display.
    """

    def __init__(self, parent):
        wx.Panel.__init__(self, parent=parent)

        self.fig = Figure((3, 3), 75)
        self.canvas = FigureCanvas(self, -1, self.fig)
        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        self.ax1 = self.fig.add_subplot(1, 1, 1)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx. GROW)
        sizer.Add(self.toolbar, 0, wx.GROW)
        self.SetSizer(sizer)
        self.Fit()

    def display_transit_raw(self, x, y):
        self.ax1.cla()
        self.ax1.scatter(x, y, s=1)
        self.force_update()

    def display_shifted(self, x, y, meanx, meany):
        self.ax1.cla()
        self.ax1.scatter(x, y, s=1)
        self.ax1.plot(meanx, meany, 'm')
        self.force_update()

    def force_update(self):
        global frame
        self.canvas.draw()
        self.Layout()
        # HACK: Hate doing this but I can't find a way around it.
        frame.force_update()
Esempio n. 30
0
class Radar_Rx_Signal_Plot(wx.Panel):
    def __init__(self, parent, *args, **kwargs):
        wx.Panel.__init__(self, parent, *args, **kwargs)
        self.SetBackgroundColour(BACKGROUND_COLOR)
        self.figure = Figure()
        self.canvas = FigureCanvas(self, 1, self.figure)
        #self.figure.set_title("Radar Target Plot")
        self.rx_signal_subplot = self.figure.add_subplot(111)
        #self.rx_signal_subplot.autoscale(tight=True)
        self.rx_signal_subplot.set_title('Rx Dechirped Signal')

        self.toolbar = NavigationToolbar(self.canvas)
        self.toolbar.Realize()

        #this seems hacky but it is the only way to start the prot
        self.rx_signal_subplot_handle = None

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.EXPAND)
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(self.sizer)
        pub.subscribe(self.update_view, "update_radar_table")

    def update_view(self, msg):
        radar_msg = Radar_Message(msg)
        if radar_msg:
            rx_signal = radar_msg.rx_signal
            self.update_rx_signal_plot(rx_signal)

    def update_rx_signal_plot(self, rx_signal):
        #voltage_z0 = 50.0 * (1e3) ** 2
        #rx_signal = voltage_z0 * rx_signal
        x = range(len(rx_signal))
        if self.rx_signal_subplot_handle == None:
            self.rx_signal_subplot_handle = self.rx_signal_subplot.plot(
                x, rx_signal)[0]
        #signal_max = max(rx_signal.real)
        self.rx_signal_subplot.set_ylim([-250, 250])
        self.rx_signal_subplot_handle.set_xdata(x)
        self.rx_signal_subplot_handle.set_ydata(rx_signal)
        self.figure.canvas.draw()