Beispiel #1
0
    def __init__(self, subplot=111, parent=None, width=5, height=4, dpi=100, 
                 figfacecolor=3*[0.941], style=None, **kwargs):

        #        super(MplCanvas, self).__init__(parent)
        if style is None:
            pass
        else:
            _mpl.style.use(style)

        # Create figure and axes
        self.fig = _Figure(figsize=(width, height), dpi=dpi, 
                           facecolor=figfacecolor, **kwargs)
        # Initialize the canvas
        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)
        
        self.setupAx(subplot=subplot, **kwargs)
        
        # Not really used, but could be used to have some sort of initial plot
        self.compute_initial_figure()

        # Set canvas size policies and geometry
        FigureCanvas.setSizePolicy(self, _QtWidgets.QSizePolicy.Expanding,
                                   _QtWidgets.QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)

        # Create the toolbar and connect to canvas (self)
        self.toolbar = _NavigationToolbar(self, None)
Beispiel #2
0
    def __init__(self, subplot=111, parent=None, width=5, height=4, dpi=100, 
                 figfacecolor=3*[0.941], style=None, **kwargs):

        #        super(MplCanvas, self).__init__(parent)
        if style is None:
            pass
        else:
            _mpl.style.use(style)
        self._mpl_v1 = _mpl.__version__.split('.')[0] == 1

        # Create figure and axes
        self.fig = _Figure(figsize=(width, height), dpi=dpi, 
                           facecolor=figfacecolor, **kwargs)
        # Initialize the canvas
        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)
        
        self.setupAx(subplot=subplot, **kwargs)
        
        # Not really used, but could be used to have some sort of initial plot
        self.compute_initial_figure()

        # Set canvas size policies and geometry
        FigureCanvas.setSizePolicy(self, _QtWidgets.QSizePolicy.Fixed,
                                   _QtWidgets.QSizePolicy.Fixed)
        FigureCanvas.updateGeometry(self)

        # Create the toolbar and connect to canvas (self)
        self.toolbar = _NavigationToolbar(self, None)
Beispiel #3
0
 def useToolBar(self, use=True):
     if use is True:
         self.toolbar = _NavigationToolbar(self.canvas,
                                           None,
                                           coordinates=True)
Beispiel #4
0
    def __init__(self,
                 data,
                 x=None,
                 plugin=None,
                 xlabel=None,
                 ylabel=None,
                 show_difference=False,
                 parent=None):
        super(DialogPlotEffect, self).__init__(parent)
        self.ui = Ui_DialogPlotEffect()
        self.ui.setupUi(self)

        self.data = data

        self.mpl_orig = _winMpl()
        self.mpl_orig.fig = _Figure(facecolor=[1, 1, 1])
        self.mpl_orig.ax = self.mpl_orig.fig.add_subplot(111)
        self.mpl_orig.canvas = _FigureCanvas(self.mpl_orig.fig)
        self.mpl_orig.toolbar = _NavigationToolbar(self.mpl_orig.canvas, None)

        self.mpl_affected = _winMpl()
        self.mpl_affected.fig = _Figure(facecolor=[1, 1, 1])
        self.mpl_affected.ax = self.mpl_affected.fig.add_subplot(111)
        self.mpl_affected.canvas = _FigureCanvas(self.mpl_affected.fig)
        self.mpl_affected.toolbar = _NavigationToolbar(
            self.mpl_affected.canvas, None)

        self.ui.verticalLayout.insertWidget(1, self.mpl_orig.canvas)
        self.ui.verticalLayout.insertWidget(1, self.mpl_orig.toolbar)

        self.ui.verticalLayout.insertWidget(3, self.mpl_affected.canvas)
        self.ui.verticalLayout.insertWidget(3, self.mpl_affected.toolbar)

        # Plugin that brings functionality to PlotEffect
        self.plugin = plugin

        # Signal emited when something changes in the plugin widget
        self.plugin.changed.connect(self.widget_changed)

        if xlabel is None:
            self.ui.xlabel = self.XLABEL
        else:
            self.ui.xlabel = xlabel

        if ylabel is None:
            self.ui.ylabel = self.YLABEL
        else:
            self.ui.ylabel = ylabel

        if x is None:
            self.x = _np.linspace(0, data.shape[0], self.data.shape[0])
        else:
            self.x = x

        self.show_diff = show_difference

        if not isinstance(data, list):
            try:
                self.mpl_orig.ax.plot(self.x, data)
            except:
                self.mpl_orig.ax.plot(self.x, data.T)

            self.mpl_orig.ax.xaxis.set_label_text(self.ui.xlabel)
            self.mpl_orig.ax.yaxis.set_label_text(self.ui.ylabel)
            #            self.mpl_orig.fig.tight_layout(rect=[-.05,0.05,1,.95])
            self.mpl_orig.ax.set_title('Original')
        else:
            if self.plugin is not None:

                try:
                    self.mpl_orig.ax.plot(self.x, self.plugin.fcn(self.data))
                except:
                    self.mpl_orig.ax.plot(self.x, self.plugin.fcn(self.data).T)

                self.mpl_orig.ax.xaxis.set_label_text(self.ui.xlabel)
                self.mpl_orig.ax.yaxis.set_label_text(self.ui.ylabel)
                #                self.mpl_orig.fig.tight_layout(rect=[0,0.05,1,.9])
                self.mpl_orig.ax.set_title('Original')

        if self.plugin is not None:
            self.ui.verticalLayout.insertWidget(8, plugin)

        self.widget_changed()
        self.mpl_orig.canvas.draw()
        self.mpl_affected.canvas.draw()

        self.ui.pushButtonOk.clicked.connect(self.accept)
        self.ui.pushButtonCancel.clicked.connect(self.reject)