Ejemplo n.º 1
0
 def _init_toolbar(self):
     selectAction = self.addAction(QIcon(":/plugins/spatialplot/action.png"), 'Select Features', self.select_mode)
     selectAction.setToolTip('Click and drag the plot to select features in the QGIS interface.')
     selectAction.setCheckable(True)
     self._actions['select'] = selectAction
     
     NavigationToolbar2QTAgg._init_toolbar(self)
Ejemplo n.º 2
0
class MplCanvas(FigureCanvas):
    def __init__(self, parent=None, width=5, height=4, dpi=100):
        matplotlib.rcParams['font.size'] = 8
        self.figure = Figure(figsize=(width, height), dpi=dpi)
        self.axes = self.figure.add_subplot(111)

        FigureCanvas.__init__(self, self.figure)
        self.setParent(parent)
        
        self.toolbar = NavigationToolbar(self, parent)
        self.toolbar.setIconSize(QSize(16, 16))

        FigureCanvas.setSizePolicy(self,
                                   QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
        
    def getToolbar(self):
        return self.toolbar

    def clear(self):
        self.figure.clear()
        self.axes = self.figure.add_subplot(111)
        
    def test(self):
        self.axes.plot([1,2,3,4])
        
    def saveAs(self, fname):
        self.figure.savefig(fname)
Ejemplo n.º 3
0
class MatplotlibPlot:
    """ Class encapsulating a matplotlib plot"""

    def __init__(self, parent = None, dpi = 100, size = (5,5)):
        """ Class initialiser """

        self.dpi = dpi
        self.figure = Figure(size, dpi = self.dpi)
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setParent(parent)

        # Create the navigation toolbar, tied to the canvas
        self.toolbar = NavigationToolbar(self.canvas, parent)
        self.canvas.show()
        self.toolbar.show()

        # Reset the plot landscape
        self.figure.clear()

    def plotMultiPixel(self, info, data):
        """ Generate multi-pixel plot """

        # Tabula Rasa
        self.figure.clear()
        rows = math.ceil(math.sqrt(info['nbeams']))

	    # Display a subplot per beam (randomly for now)
        for i in range(info['nbeams']):
            ax = self.figure.add_subplot(rows, rows, i)
            ax.plot(data[:,512,i])
            
        

    def updatePlot(self):
        self.canvas.draw()
class PlotWidget(QWidget):
    def __init__(self, parent=None):
        super(PlotWidget, self).__init__(parent)
        # create widgets
        self.canvas = PlotCanvas()
        self.toolbar = NavigationToolbar(self.canvas, self.canvas)
        self.toolbar.setSizePolicy(QSizePolicy.Preferred,
                                   QSizePolicy.Preferred)
        vbox = QVBoxLayout()
        vbox.addWidget(self.toolbar)
        vbox.addWidget(self.canvas)
        self.setLayout(vbox)

    def draw_curves(self, curve_names, data):
        self.canvas.axes.clear()
        self.canvas.axes.grid(True, color='gray')
        for name in curve_names:
            xdata, ydata = data[name]
            self.canvas.axes.plot(xdata, ydata, 'o-', label=name)[0]
        self.update_legend()
        self.canvas.draw()

    def update_legend(self):
        handles, labels = self.canvas.axes.get_legend_handles_labels()
        self.canvas.axes.legend(handles, labels, loc='upper left')
Ejemplo n.º 5
0
 def __init__(self, widgimage, parent=None):
     #print 'ImgSpeNavToolBar.__init__'
     self.widgimage  = widgimage
     self.canvas     = self.widgimage.getCanvas()
     fig = self.canvas.figure
     fig.ntbZoomIsOn = False
     NavigationToolbar.__init__( self, self.canvas, parent )
Ejemplo n.º 6
0
 def __init__(self, widgimage, parent=None):
     #print 'ImgSpeNavToolBar.__init__'
     self.widgimage  = widgimage
     self.canvas     = self.widgimage.getCanvas()
     fig = self.canvas.figure
     fig.ntbZoomIsOn = False
     NavigationToolbar.__init__( self, self.canvas, parent )
class plotwidget(FigureCanvas):
    def __init__(self, parent, width=12, height=6, dpi=72, projection3d=False):

        #plotdata can be 2d array for image plot or list of 2 1d arrays for x-y plot or 2d array for image plot or list of lists of 2 1D arrays

        self.fig = Figure(figsize=(width, height), dpi=dpi)
        if projection3d:
            self.axes = self.fig.add_subplot(111,
                                             navigate=True,
                                             projection='3d')
        else:
            self.axes = self.fig.add_subplot(111, navigate=True)

        self.axes.hold(True)
        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)
        #self.parent=parent
        FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
        #NavigationToolbar(self, parent)

        self.toolbar = NavigationToolbar(self.figure.canvas, self)
        self.toolbar.setMovable(True)  #DOESNT DO ANYTHING
        self.mpl_connect('button_press_event', self.myclick)
        self.clicklist = []

    def myclick(self, event):
        if not (event.xdata is None or event.ydata is None):
            arrayxy = [event.xdata, event.ydata]
            print 'clicked on image: array indeces ', arrayxy, ' using button', event.button
            self.clicklist += [arrayxy]
            self.emit(SIGNAL("genericclickonplot"),
                      [event.xdata, event.ydata, event.button])
class plotwidget(FigureCanvas):
    def __init__(self, parent, width=12, height=6, dpi=72, projection3d=False):

        #plotdata can be 2d array for image plot or list of 2 1d arrays for x-y plot or 2d array for image plot or list of lists of 2 1D arrays

        self.fig=Figure(figsize=(width, height), dpi=dpi)
        if projection3d:
            self.axes=self.fig.add_subplot(111, navigate=True, projection='3d')
        else:
            self.axes=self.fig.add_subplot(111, navigate=True)

        self.axes.hold(True)
        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)
        #self.parent=parent
        FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding, QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
        #NavigationToolbar(self, parent)
        
        self.toolbar=NavigationToolbar(self.figure.canvas, self)
        self.toolbar.setMovable(True)#DOESNT DO ANYTHING
        self.mpl_connect('button_press_event', self.myclick)
        self.clicklist=[]

    def myclick(self, event):
        if not (event.xdata is None or event.ydata is None):
            arrayxy=[event.xdata, event.ydata]
            print 'clicked on image: array indeces ', arrayxy, ' using button', event.button
            self.clicklist+=[arrayxy]
            self.emit(SIGNAL("genericclickonplot"), [event.xdata, event.ydata, event.button])
Ejemplo n.º 9
0
 def __init__(self,canvas,parent):
     #NavigationToolbar.__init__(self,parent,canevas)
     #self.layout = QVBoxLayout( self )
     self.canvas = canvas
     #QtGui.QWidget.__init__(self, parent)
     #self.layout.setMargin( 2 )
     #self.layout.setSpacing( 0 )
     NavigationToolbar.__init__(self, canvas, canvas)
Ejemplo n.º 10
0
 def __init__(self, canvas, parent, browser):
     NavigationToolbar2QTAgg.__init__(self,canvas,parent)
     for c in self.findChildren(QtGui.QToolButton):
         #print str(c.text())
         if str(c.text()) in ('Subplots','Customize','Back','Forward','Home'):
             c.defaultAction().setVisible(False)
     self.parent = parent
     self.browser = browser
Ejemplo n.º 11
0
 def home(self, *args) :
     print 'Home is clicked'
     fig = self.canvas.figure
     fig.myXmin = None
     fig.myXmax = None
     fig.myYmin = None
     fig.myYmax = None
     NavigationToolbar.home(self)
Ejemplo n.º 12
0
 def home(self, *args):
     print 'Home is clicked'
     fig = self.canvas.figure
     fig.myXmin = None
     fig.myXmax = None
     fig.myYmin = None
     fig.myYmax = None
     NavigationToolbar.home(self)
Ejemplo n.º 13
0
    def __init__(self, parent, canvas):
        """ Initialization
        """
        NavigationToolbar2.__init__(self, canvas, canvas)

        self._myParent = parent
        self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE

        return
Ejemplo n.º 14
0
    def __init__(self, parent, canvas):
        """ Initialization
        """
        NavigationToolbar2.__init__(self, canvas, canvas)

        self._myParent = parent
        self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE

        return
Ejemplo n.º 15
0
	def __init__(self, *args, **kwargs):
		NavigationToolbar2QTAgg.__init__(self, *args, **kwargs)

		self.init_buttons()
		self.panAction.setCheckable(True)
		self.zoomAction.setCheckable(True)

		# remove the subplots action
		self.removeAction( self.subplotsAction )
Ejemplo n.º 16
0
    def __init__(self, *args, **kwargs):
        NavigationToolbar2QTAgg.__init__(self, *args, **kwargs)

        self.init_buttons()
        self.panAction.setCheckable(True)
        self.zoomAction.setCheckable(True)

        # remove the subplots action
        self.removeAction(self.subplotsAction)
Ejemplo n.º 17
0
 def __init__(self, canvas, parent, browser):
     NavigationToolbar2QTAgg.__init__(self, canvas, parent)
     for c in self.findChildren(QtGui.QToolButton):
         #print str(c.text())
         if str(c.text()) in ('Subplots', 'Customize', 'Back', 'Forward',
                              'Home'):
             c.defaultAction().setVisible(False)
     self.parent = parent
     self.browser = browser
Ejemplo n.º 18
0
class MplWidgetT(QtGui.QWidget):
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.canvas = MplCanvas()
        self.ntb = NavigationToolbar(self.canvas, self)
        self.ntb.setIconSize(QtCore.QSize(16, 16))
        self.vbl = QtGui.QVBoxLayout()
        self.vbl.addWidget(self.canvas)
        self.vbl.addWidget(self.ntb)
        self.setLayout(self.vbl)
Ejemplo n.º 19
0
    def _update_view(self):
        """
        view update called by home(), back() and forward()
        :return:
        """
        NavigationToolbar2._update_view(self)

        self._myParent.evt_view_updated()

        return
Ejemplo n.º 20
0
    def _update_view(self):
        """
        view update called by home(), back() and forward()
        :return:
        """
        NavigationToolbar2._update_view(self)

        self._myParent.evt_view_updated()

        return
Ejemplo n.º 21
0
    def draw(self):
        """
        Canvas is drawn called by pan(), zoom()
        :return:
        """
        NavigationToolbar2.draw(self)

        self._myParent.evt_view_updated()

        return
Ejemplo n.º 22
0
    def draw(self):
        """
        Canvas is drawn called by pan(), zoom()
        :return:
        """
        NavigationToolbar2.draw(self)

        self._myParent.evt_view_updated()

        return
Ejemplo n.º 23
0
class MplWidgetT(QtGui.QWidget):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.canvas = MplCanvas()
        self.ntb = NavigationToolbar(self.canvas, self)
        self.ntb.setIconSize(QtCore.QSize(16, 16))
        self.vbl = QtGui.QVBoxLayout()
        self.vbl.addWidget(self.canvas)
        self.vbl.addWidget(self.ntb)
        self.setLayout(self.vbl)
Ejemplo n.º 24
0
 def NewFigure_proc(self):
     widget = QtGui.QWidget(self.MainFigTabWidget)
     vlay = QtGui.QVBoxLayout(widget)
     self.Figures.append(MplWidget(widget))
     ntb = NavToolbar(self.Figures[-1], parent = widget)
     ntb.setIconSize(QtCore.QSize(15,15))
     vlay.setSpacing(0)
     vlay.setMargin(0)
     vlay.addWidget(self.Figures[-1])
     vlay.addWidget(ntb)
     widget.setLayout(vlay)
     self.MainFigTabWidget.addTab(widget, 'Figure '+str(len(self.Figures)))
     widget.setObjectName(str(self.MainFigTabWidget.count()))
     self.Figures[-1].setObjectName(str(self.MainFigTabWidget.count()))
Ejemplo n.º 25
0
class MatplotlibPlot:
    """ Class encapsulating an matplotlib plot"""
    def __init__(self, parent=None, dpi=100, size=(5, 4)):
        """ Class initialiser """

        self.dpi = dpi
        self.figure = Figure(size, dpi=self.dpi)
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setParent(parent)

        # Create the navigation toolbar, tied to the canvas
        self.toolbar = NavigationToolbar(self.canvas, parent)
        self.canvas.show()
        self.toolbar.show()

    def plotCurve(self,
                  data,
                  xAxisRange=None,
                  yAxisRange=None,
                  xLabel="",
                  yLabel=""):
        """ Plot the data as a curve"""

        # clear the axes and redraw the plot anew
        self.figure.clear()
        self.axes = self.figure.add_subplot(111)
        self.axes.grid(True)
        self.axes.plot(range(np.size(data)), data)

        if xAxisRange is not None:
            self.xAxisRange = xAxisRange
            self.axes.xaxis.set_major_formatter(
                ticker.FuncFormatter(
                    lambda x, pos=None: '%.2f' % self.xAxisRange[x]
                    if 0 <= x < len(xAxisRange) else ''))
            for tick in self.axes.xaxis.get_ticklabels():
                tick.set_rotation(15)

        if yAxisRange is not None:
            self.yAxisRange = yAxisRange
            self.axes.xaxis.set_major_formatter(
                ticker.FuncFormatter(
                    lambda x, pos=None: '%.1f' % self.yAxisRange[y]
                    if 0 <= y < len(yAxisRange) else ''))
            for tick in self.axes.yaxis.get_ticklabels():
                tick.set_rotation(15)

        self.axes.xaxis.set_label_text(xLabel)
        self.axes.yaxis.set_label_text(yLabel)
        self.canvas.draw()
    def __init__(self, parent, width=12, height=6, dpi=72, projection3d=False):

        #plotdata can be 2d array for image plot or list of 2 1d arrays for x-y plot or 2d array for image plot or list of lists of 2 1D arrays

        self.fig = Figure(figsize=(width, height), dpi=dpi)
        if projection3d:
            self.axes = self.fig.add_subplot(111,
                                             navigate=True,
                                             projection='3d')
        else:
            self.axes = self.fig.add_subplot(111, navigate=True)

        self.axes.hold(True)
        FigureCanvas.__init__(self, self.fig)
        self.setParent(parent)
        #self.parent=parent
        FigureCanvas.setSizePolicy(self, QSizePolicy.Expanding,
                                   QSizePolicy.Expanding)
        FigureCanvas.updateGeometry(self)
        #NavigationToolbar(self, parent)

        self.toolbar = NavigationToolbar(self.figure.canvas, self)
        self.toolbar.setMovable(True)  #DOESNT DO ANYTHING
        self.mpl_connect('button_press_event', self.myclick)
        self.clicklist = []
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
 
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
 
         
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()
 
        # Just some button 
        self.button = QtGui.QPushButton('Plot')
        self.button.clicked.connect(self.plot)
 
        self.button1 = QtGui.QPushButton('Zoom')
        self.button1.clicked.connect(self.zoom)
         
        self.button2 = QtGui.QPushButton('Pan')
        self.button2.clicked.connect(self.pan)
         
        self.button3 = QtGui.QPushButton('Home')
        self.button3.clicked.connect(self.home)
 
 
        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)
        layout.addWidget(self.button)
        layout.addWidget(self.button1)
        layout.addWidget(self.button2)
        layout.addWidget(self.button3)
        self.setLayout(layout)
Ejemplo n.º 28
0
   def __init__(self, parent, corrmatrix):
     QFrame.__init__(self)
    
     self.setWindowTitle("Correlation Matrix")
     
     self.corrmatrix=[[]]
     self.rank=None
     self.rim=0.05
  
     self.parent=parent            # parent object/class
     self.fig=None
  
     # Create canvas for plotting
     self.fig = Figure((7, 7), dpi=100)
     self.canvas = FigureCanvas(self.fig)
     self.canvas.setParent(self)
     self.fig.subplots_adjust(left=self.rim, right=1.0-self.rim, top=1.0-self.rim, bottom=self.rim)  # set a small rim
     self.ax=self.fig.add_subplot(111)

     self.mpl_toolbar = NavigationToolbar(self.canvas, self)
     self.mpl_toolbar.show()
  
     self.setMinimumWidth(700)
     self.setMinimumHeight(700)
     self.corrmatrix=corrmatrix

     self.xLabel="Parameter index"
     self.yLabel="Parameter index"

     self.createWidgets()
     self.createLayouts()
     self.connectSignals()
     self.plot(self.corrmatrix)
Ejemplo n.º 29
0
 def _createPlotWidget(self):
     self._plotWidget = QtGui.QWidget()
     self._plotFigure = Figure()
     self._plotCanvas = FigureCanvas(self._plotFigure)
     self._plotCanvas.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
     self._plotCanvas.updateGeometry()
     self._plotCanvas.setParent(self._plotWidget)
     self._plotCanvas.mpl_connect('scroll_event', self._onScroll)
     self._plotFigure.set_canvas(self._plotCanvas)
     # Vm and command voltage go in the same subplot
     self._vm_axes = self._plotFigure.add_subplot(2,2,1, title='Membrane potential')
     self._vm_axes.set_ylim(-20.0, 120.0)
     # Channel conductances go to the same subplot
     self._g_axes = self._plotFigure.add_subplot(2,2,2, title='Channel conductance')
     self._g_axes.set_ylim(0.0, 0.5)
     # Injection current for Vclamp/Iclamp go to the same subplot
     self._im_axes = self._plotFigure.add_subplot(2,2,3, title='Injection current')
     self._im_axes.set_ylim(-0.5, 0.5)
     # Channel currents go to the same subplot
     self._i_axes = self._plotFigure.add_subplot(2,2,4, title='Channel current')
     self._i_axes.set_ylim(-10, 10)
     for axis in self._plotFigure.axes:
         axis.set_autoscale_on(False)
     layout = QtGui.QVBoxLayout()
     layout.addWidget(self._plotCanvas)
     self._plotNavigator = NavigationToolbar(self._plotCanvas, self._plotWidget)
     layout.addWidget(self._plotNavigator)
     self._plotWidget.setLayout(layout)
Ejemplo n.º 30
0
    def pan(self, *args):
        """

        :param args:
        :return:
        """
        NavigationToolbar2.pan(self, args)

        if self._navigationMode == MyNavigationToolbar.NAVIGATION_MODE_PAN:
            # out of pan mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE
        else:
            # into pan mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_PAN

        return
Ejemplo n.º 31
0
    def zoom(self, *args):
        """
        Turn on/off zoom (zoom button)
        :param args:
        :return:
        """
        NavigationToolbar2.zoom(self, args)

        if self._navigationMode == MyNavigationToolbar.NAVIGATION_MODE_ZOOM:
            # out of zoom mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE
        else:
            # into zoom mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_ZOOM

        return
Ejemplo n.º 32
0
    def create_main_frame(self):
        self.setFocusPolicy(QtCore.Qt.ClickFocus)
        self.dpi = 100
        self.fig = Figure((5.0, 4.0), dpi=self.dpi)

#        self.fig.subplots_adjust(left = 0.01, right=0.99, top=0.99, bottom=0.001)
        self.fig.subplots_adjust(left = 0, right=1, top=1, bottom=0)
        self.map_canvas = MyMapCanvas(self.fig)
        self.map_canvas.mpl_connect('scroll_event', self.wheel_zoom)
#        self.connect(self, QtCore.SIGNAL('keyPressEvent(QString)'),
#             self.key_press)
        self.map_canvas.mpl_connect('button_release_event', self.button_up)
        self.map_canvas.mpl_connect('resize_event', self._resize)
        self.add_axis()

        self.mpl_toolbar = NavigationToolbar(self.map_canvas, None)



        self.mpl_toolbar.pan()

#        self.popMenu = popup_menu(self, self.mpl_toolbar)
        self.popMenu = None

        self.map_canvas.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
        self.connect(self.map_canvas, QtCore.SIGNAL('customContextMenuRequested(const QPoint&)'), self.on_context_menu)

        self.layout().addWidget(self.map_canvas)
Ejemplo n.º 33
0
    def _refresh_mpl_widget(self):
        """ Create the mpl widget and update the underlying control.

        """
        # Delete the old widgets in the layout, it's just shenanigans
        # to try to reuse the old widgets when the figure changes.
        widget = self.widget
        layout = widget.layout()
        while layout.count():
            layout_item = layout.takeAt(0)
            layout_item.widget().deleteLater()

        # Create the new figure and toolbar widgets. It seems that key
        # events will not be processed without an mpl figure manager.
        # However, a figure manager will create a new toplevel window,
        # which is certainly not desired in this case. This appears to
        # be a limitation of matplotlib. The canvas is manually set to
        # visible, or QVBoxLayout will ignore it for size hinting.
        figure = self.declaration.figure
        if figure:
            canvas = FigureCanvasQTAgg(figure)
            canvas.setParent(widget)
            canvas.setFocusPolicy(Qt.ClickFocus)
            canvas.setVisible(True)
            toolbar = NavigationToolbar2QTAgg(canvas, widget)
            toolbar.setVisible(self.declaration.toolbar_visible)
            layout.addWidget(toolbar)
            layout.addWidget(canvas)
Ejemplo n.º 34
0
 def gui_graph(self, wgt, lay_graph, lay_toolbar=None):
     lay_graph.addWidget(self.canvas)
     self.toolbar = NavigationToolbar(self.canvas, wgt)
     if lay_toolbar is not None:
         lay_toolbar.addWidget(self.toolbar)
     else:
         lay_graph.addWidget(self.toolbar)
 def initUI(self):
     self.table_ComboBox_1.clear()  
     self.table_ComboBox_2.clear()  
     self.table_ComboBox_3.clear()  
     for i in range (1,3):
         self.clearthings(1)
     # function partial due to problems with currentindexChanged and Combobox
     #self.connect(self.table_ComboBox_1, QtCore.SIGNAL("currentIndexChanged(int)"), partial(self.Table1Changed))#currentIndexChanged caused unnecessary signals when scrolling in combobox
     self.connect(self.table_ComboBox_1, QtCore.SIGNAL("activated(int)"), partial(self.Table1Changed))  
     self.connect(self.Filter1_ComboBox_1, QtCore.SIGNAL("activated(int)"), partial(self.Filter1_1Changed))
     #self.connect(self.Filter1_ComboBox_1, QtCore.SIGNAL("activated(int)"), partial(self.FilterChanged(1,1)))
     self.connect(self.Filter2_ComboBox_1, QtCore.SIGNAL("activated(int)"), partial(self.Filter2_1Changed)) 
     self.connect(self.table_ComboBox_2, QtCore.SIGNAL("activated(int)"), partial(self.Table2Changed)) 
     self.connect(self.Filter1_ComboBox_2, QtCore.SIGNAL("activated(int)"), partial(self.Filter1_2Changed))
     self.connect(self.Filter2_ComboBox_2, QtCore.SIGNAL("activated(int)"), partial(self.Filter2_2Changed)) 
     self.connect(self.table_ComboBox_3, QtCore.SIGNAL("activated(int)"), partial(self.Table3Changed)) 
     self.connect(self.Filter1_ComboBox_3, QtCore.SIGNAL("activated(int)"), partial(self.Filter1_3Changed))
     self.connect(self.Filter2_ComboBox_3, QtCore.SIGNAL("activated(int)"), partial(self.Filter2_3Changed)) 
     self.PlotChart_QPushButton.clicked.connect(self.drawPlot)
     self.Redraw_pushButton.clicked.connect( self.refreshPlot )
     
     # Create a plot window with one single subplot
     self.custplotfigure = plt.figure() 
     self.axes = self.custplotfigure.add_subplot( 111 )
     self.canvas = FigureCanvas( self.custplotfigure )
     self.mpltoolbar = NavigationToolbar( self.canvas, self.widgetPlot )
     lstActions = self.mpltoolbar.actions()
     self.mpltoolbar.removeAction( lstActions[ 7 ] )
     self.layoutplot.addWidget( self.canvas )
     self.layoutplot.addWidget( self.mpltoolbar )
     
     self.show()
Ejemplo n.º 36
0
    def __init__(self, parent=None):
        super(Grafica, self).__init__()

        # FIGUREANDO
        self.ordenadas = np.arange(5)
        self.width = 1       # the width of the bars
        self.figure, self.ax = plt.subplots()
        #self.figure = plt.figure()
        self.line = self.ax.bar(self.ordenadas, self.valores, self.width, color='g')
        #self.line, = plt.plot(self.data)
        plt.ion() # animate

        N = 10
        self.xs = collections.deque(maxlen=N)
        self.ys = collections.deque(maxlen=N)
        self.xs.append(0)
        self.ys.append(0)

        self.ax = self.figure.add_subplot(111)
        self.ax.hold(False)
        self.ax.set_ylim([0, 360])

        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()
        self.canvas.show()

        # set the layout
        self.layout = QVBoxLayout()
        self.layout.addWidget(self.toolbar)
        self.layout.addWidget(self.canvas)
        self.setLayout(self.layout)
Ejemplo n.º 37
0
    def pan(self, *args):
        """

        :param args:
        :return:
        """
        NavigationToolbar2.pan(self, args)

        if self._navigationMode == MyNavigationToolbar.NAVIGATION_MODE_PAN:
            # out of pan mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE
        else:
            # into pan mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_PAN

        return
Ejemplo n.º 38
0
  def __init__(self, plugin, parent=None):
    QWidget.__init__(self, parent)
    self.setupUi(self)

    self.plugin = plugin
    self.inputs = plugin.inputs
    self.settings = QSettings("NextGIS", "MOLUSCE")

    # init plot for learning curve
    self.figure = Figure()
    self.axes = self.figure.add_subplot(111)
    self.figure.suptitle(self.tr("Neural Network learning curve"))
    self.canvas = FigureCanvas(self.figure)
    self.mpltoolbar = NavigationToolbar(self.canvas, None)
    lstActions = self.mpltoolbar.actions()
    self.mpltoolbar.removeAction(lstActions[7])
    self.layoutPlot.addWidget(self.canvas)
    self.layoutPlot.addWidget(self.mpltoolbar)

    # and configure matplotlib params
    rcParams['font.serif'] = "Verdana, Arial, Liberation Serif"
    rcParams['font.sans-serif'] = "Tahoma, Arial, Liberation Sans"
    rcParams['font.cursive'] = "Courier New, Arial, Liberation Sans"
    rcParams['font.fantasy'] = "Comic Sans MS, Arial, Liberation Sans"
    rcParams['font.monospace'] = "Courier New, Liberation Mono"

    self.btnTrainNetwork.clicked.connect(self.trainNetwork)

    self.manageGui()
Ejemplo n.º 39
0
    def __init__(self, parent=None, title="Figrue", point_num=300, x=[], y=[]):
        super(FigureWidget, self).__init__(parent)

        # 数据初始化
        self.x = x
        self.y = y
        # 绘图控件初始化
        self.fig = Figure(figsize=(20, 6))
        self.fig.subplots_adjust(left=0.05, bottom=0.1, right=0.95, top=0.9, wspace=None, hspace=None)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self)
        self.mpl_toolbar = NavigationToolbar(self.canvas, self)
        self.mpl_toolbar.setVisible(False)

        # 控件摆放设置
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.canvas)
        vbox.addWidget(self.mpl_toolbar)
        # vbox.addLayout(hbox)
        self.setLayout(vbox)

        # 创建右键菜单
        # self.createContextMenu()

        # 设置子图属性
        self.ax = self.fig.add_subplot(111)
        self.ax.set_title(title)
        # self.ax.patch.set_facecolor('#888888')
        self.ax.autoscale_view()
        self.data, = self.ax.plot(self.x, self.y, label='analysis')
        self.ax.legend()
        # # force a redraw of the Figure

        self.fig.canvas.draw()
Ejemplo n.º 40
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
 
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
 
         
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()
 
##        # Start Button
##        self.button = QtGui.QPushButton('Start')
##        self.button.clicked.connect(self.plot)
##        
        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.canvas)
##        layout.addWidget(self.button)
        self.setLayout(layout)

        global ser, Array, num_rows, num_cols, Matrix, count, sensor_num
        ser = sensorInit()
        num_rows = 7
        num_cols = 4
        Array = bytearray(num_rows*num_cols)
        Matrix = np.zeros((num_cols,num_rows))
        
        count = 33
        sensor_num = 24
        #timer info
        self.timer = QtCore.QBasicTimer()
        self.timer.start(count, self)
        self.step = 0
Ejemplo n.º 41
0
   def __init__(self, parent):
      print "__init__()"       # DEBUG
      QFrame.__init__(self)
      
      self.parent=parent
      #self.setModal(False)

      self.data1=self.parent.y1   # get plotted y values from solutions plot
      self.data2=self.parent.y2   # get plotted y values from parameter plot
      self.nbins=50               # default=50 bins
      self.parameter=self.parent.parent.parametersComboBox.currentText()
      self.data=self.parent.y2    # set histogram to solver parameter data

      #print "self.data = ", self.data   # DEBUG

      # Create canvas for plotting
      self.rim=0.1
      self.fig = Figure((5, 4), dpi=100)
      self.canvas = FigureCanvas(self.fig)
      self.canvas.setParent(self)
      self.fig.subplots_adjust(left=self.rim, right=1.0-self.rim, top=1.0-self.rim, bottom=self.rim)  # set a small rim

      self.mpl_toolbar = NavigationToolbar(self.canvas, self)
      self.mpl_toolbar.show()   # first hide the toolbar
      
      self.ax=self.fig.add_subplot(111)
      
      self.createWidgets()
      self.createLayout()
      self.connectSignals()
      self.setLabels()
      self.plot()
Ejemplo n.º 42
0
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)

        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)


        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()

        # Just some button
        self.button = QtGui.QPushButton('Plot')
        self.button.clicked.connect(self.plot)

        self.button1 = QtGui.QPushButton('Zoom')
        self.button1.clicked.connect(self.zoom)

        self.button2 = QtGui.QPushButton('Pan')
        self.button2.clicked.connect(self.pan)

        self.button3 = QtGui.QPushButton('Home')
        self.button3.clicked.connect(self.home)


        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)
        layout.addWidget(self.button)
        layout.addWidget(self.button1)
        layout.addWidget(self.button2)
        layout.addWidget(self.button3)
        self.setLayout(layout)
Ejemplo n.º 43
0
 def buildUi(self):
     self.verticalLayout = QVBoxLayout(self)
     self.figure = Figure()
     self.canvas = Canvas(self.figure)	                # <-- figure required
     self.navigationToolbar = NavigationToolbar(self.canvas, self)
     self.verticalLayout.addWidget(self.canvas)
     self.verticalLayout.addWidget(self.navigationToolbar)
Ejemplo n.º 44
0
    def __init__(self, plugin, parent=None):
        QWidget.__init__(self, parent)
        self.setupUi(self)

        self.plugin = plugin
        self.inputs = plugin.inputs
        self.settings = QSettings("NextGIS", "MOLUSCE")

        # init plot for learning curve
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        self.figure.suptitle(self.tr("Neural Network learning curve"))
        self.canvas = FigureCanvas(self.figure)
        self.mpltoolbar = NavigationToolbar(self.canvas, None)
        lstActions = self.mpltoolbar.actions()
        self.mpltoolbar.removeAction(lstActions[7])
        self.layoutPlot.addWidget(self.canvas)
        self.layoutPlot.addWidget(self.mpltoolbar)

        # and configure matplotlib params
        rcParams['font.serif'] = "Verdana, Arial, Liberation Serif"
        rcParams['font.sans-serif'] = "Tahoma, Arial, Liberation Sans"
        rcParams['font.cursive'] = "Courier New, Arial, Liberation Sans"
        rcParams['font.fantasy'] = "Comic Sans MS, Arial, Liberation Sans"
        rcParams['font.monospace'] = "Courier New, Liberation Mono"

        self.btnTrainNetwork.clicked.connect(self.trainNetwork)

        self.manageGui()
Ejemplo n.º 45
0
    def zoom(self, *args):
        """
        Turn on/off zoom (zoom button)
        :param args:
        :return:
        """
        NavigationToolbar2.zoom(self, args)

        if self._navigationMode == MyNavigationToolbar.NAVIGATION_MODE_ZOOM:
            # out of zoom mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_NONE
        else:
            # into zoom mode
            self._navigationMode = MyNavigationToolbar.NAVIGATION_MODE_ZOOM

        return
Ejemplo n.º 46
0
 def __init__(self, h5file = None):
     QtGui.QWidget.__init__(self)        
     # define a right side control panel
     gLay = QtGui.QGridLayout()
     row = 0
     
     if isinstance(h5file, tables.file.File):
         self.h5file = h5file
         
     elif isinstance(h5file, str):
         self.h5file = str(QtGui.QFileDialog.getOpenFileName(caption='select an h5 file',
                                                             filter='*.h5'))
         if self.h5file:
             self.h5file = tables.openFile(self.h5file, 'r')
     
     elif not h5file:
         self.loadH5FileBtn = QtGui.QPushButton('Load H5File')
         self.loadH5FileBtn.clicked.connect(self.loadH5FileProc)
         gLay.addWidget(self.loadH5FileBtn, row, 0, 1, 2)
         row += 1
         self.setWindowTitle('Spike Sorting Quality Explorer')
             
     self.FirstUnitCombo = QtGui.QComboBox()
     gLay.addWidget(self.FirstUnitCombo, row, 0, 1, 2)
     row += 1
     
     self.selectBtn = QtGui.QPushButton('Select None')
     self.selectBtn.clicked.connect(self.selectProc)
     self.selectBtn.setCheckable(True)
     gLay.addWidget(self.selectBtn, row, 0)
     
     self.plotXCorrBtn = QtGui.QPushButton('Plot xCorr')
     self.plotXCorrBtn.clicked.connect(self.plotXCorr)
     gLay.addWidget(self.plotXCorrBtn, row, 1)
     row += 1
     
     self.UnitsSelector = QtGui.QTableWidget(0, 1)
     self.UnitsSelector.verticalHeader().setVisible(False)
     self.UnitsSelector.horizontalHeader().setVisible(False)
     self.UnitsSelector.setColumnWidth(0, 200)
     gLay.addWidget(self.UnitsSelector, row, 0, 1, 2)
     row += 1
     
     mainLay = QtGui.QHBoxLayout(self)
     mainLay.addLayout(gLay)
     
     # define a left side figure
     vLay = QtGui.QVBoxLayout()
     self.mainFig = MplWidget(self)
     self.mainFig.figure.set_facecolor('k')
     self.ntb = NavToolbar(self.mainFig, self)
     self.ntb.setIconSize(QtCore.QSize(15, 15))
     vLay.addWidget(self.mainFig)
     vLay.addWidget(self.ntb)
 
     mainLay.addLayout(vLay)        
     
     self.show()
     
     self.UnitChecks = []
Ejemplo n.º 47
0
    def __init__(self,
                 complexData,
                 parent=None,
                 dataType=None,
                 initMarkerPosn=None,
                 colors=None,
                 title=None):
        #
        # Qt related initialization
        #
        self.fig = mpl.figure.Figure()
        FigureCanvas.__init__(self, self.fig)
        self.setParent(
            parent
        )  #the FigureCanvas class doesn't have the option to pass the parent to the __init__() constructer, must set it manually
        FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding,
                                   QtGui.QSizePolicy.Expanding)
        self.setMinimumSize(200, 200)
        FigureCanvas.updateGeometry(self)

        #
        # Event related initialization
        #
        self.mpl_connect('button_press_event', self.PressEvent)
        #self.setFocusPolicy(QtCore.Qt.StrongFocus)
        #self.mpl_connect('key_press_event',self.keyPressEventsdd)

        #
        # Internal data model initialization
        #
        self.setComplexData(complexData)
        if dataType is None:
            self.setDataType(dd.ImageType.mag)
        else:
            self.setDataType(dataType)
        self.setMarkerPosn(initMarkerPosn)

        #
        #Initialize internal variables that determine how visualization objects display data model
        #
        self.colors = colors
        if self.colors == None:
            self.colors = dd.PlotColours.colours

        #
        # Initialize objects visualizing the internal data model
        #
        #1d plot
        self.axes = self.fig.add_subplot(111)
        if title is not None:
            self.axes.set_title(title)
        #zoom functionality
        self.toolbar = NavigationToolbar2QTAgg(self, self)
        self.toolbar.hide()
        self.toolbar.zoom()
        #initialization of lines and markers
        self.createLines()
        self.createMarkers()
Ejemplo n.º 48
0
    def __init__(self, canvas, win):
        NavigationToolbar.__init__(self, canvas, win)
        self.win = win
        path = os.path.abspath(__file__)
        dir_path = os.path.dirname(path)
        imagedir = os.path.join(dir_path,'images')

        for text, tooltip_text, image_file, callback in self.mytoolitems:
            if text is None:
                self.addSeparator()
            else:
                a = self.addAction(QtGui.QIcon(os.path.join(imagedir, image_file + ".png")),
                                         text, getattr(self, callback))
                self._actions[callback] = a
                if callback in ['zoom', 'pan']:
                    a.setCheckable(True)
                if tooltip_text is not None:
                    a.setToolTip(tooltip_text)
Ejemplo n.º 49
0
    def __init__(self, parent, canvas):
        """ Initialization
        FUTURE: direction='h'
        """
        self.canvas = canvas
        QtGui.QWidget.__init__(self, parent)

        #if direction=='h' :
        #    self.layout = QtGui.QHBoxLayout(self)
        #else :
        #    self.layout = QtGui.QVBoxLayout(self)

        #self.layout.setMargin(2)
        #self.layout.setSpacing(0)

        NavigationToolbar.__init__( self, canvas, canvas )

        return
Ejemplo n.º 50
0
class Window(QtGui.QDialog):
    def __init__(self, parent=None):
        super(Window, self).__init__(parent)
 
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
 
         
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.toolbar.hide()
 
##        # Start Button
##        self.button = QtGui.QPushButton('Start')
##        self.button.clicked.connect(self.plot)
##        
        # set the layout
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.canvas)
##        layout.addWidget(self.button)
        self.setLayout(layout)

        global ser, Array, num_rows, num_cols, Matrix, count, sensor_num
        ser = sensorInit()
        num_rows = 7
        num_cols = 4
        Array = bytearray(num_rows*num_cols)
        Matrix = np.zeros((num_cols,num_rows))
        
        count = 33
        sensor_num = 24
        #timer info
        self.timer = QtCore.QBasicTimer()
        self.timer.start(count, self)
        self.step = 0

    def timerEvent(self, event):
        if event.timerId() == self.timer.timerId():
            self.update()
            Array = readSensors(ser, sensor_num)
            Matrix = matrixConvert(Array, num_rows, num_cols)
            ax = self.figure.add_subplot(111)
            ax.imshow(Matrix, interpolation='nearest', cmap='Spectral')
            self.canvas.draw()
            super(Window, self).timerEvent(event)
Ejemplo n.º 51
0
    def _initGui(self):
        """setup the user interface"""
        self.ui = Ui_elevationDlg()
        self.ui.setupUi(self)

        #get settings
        self.s = QtCore.QSettings()
        self.loadSettings()

        self.gh = geometryHelper(self.iface)
        self.eh = elevationHelper(self.iface, self.startDir)

        #setup a message bar
        self.bar = QgsMessageBar()
        self.bar.setSizePolicy(QtGui.QSizePolicy.Minimum,
                               QtGui.QSizePolicy.Fixed)
        self.ui.verticalLayout.addWidget(self.bar)

        self.ui.buttonBox.addButton(QtGui.QPushButton("Sluiten"),
                                    QtGui.QDialogButtonBox.RejectRole)
        for btn in self.ui.buttonBox.buttons():
            btn.setAutoDefault(0)

        ##graph global vars
        self.Rubberline = None
        self.profile = None
        self.pt = None
        self.ax = None
        self.ano = None
        self.anoLbl = None
        self.counter = 0
        self.xscaleUnit = (1, "m")

        # a figure instance to plot on
        self.figure = Figure()

        #create the Canvas widget and toolbar and set graphWgt as parent
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)

        ###
        #self.ui.toolbar.layout().insertWidget(0, self.toolbar)
        self.ui.graphWgt.layout().addWidget(self.canvas)
        self.createCanvasToolbar()

        #events
        self.ui.drawBtn.clicked.connect(self.drawBtnClicked)
        self.figure.canvas.mpl_connect('motion_notify_event',
                                       self.showGraphMotion)
        self.ui.saveLineBtn.clicked.connect(self.saveLineClicked)
        self.ui.savePntBtn.clicked.connect(self.savePntClicked)
        self.ui.addDHMbtn.clicked.connect(self.addDHMasWMS)
        self.ui.refreshBtn.clicked.connect(self.onRefresh)
        self.ui.buttonBox.helpRequested.connect(self.openHelp)

        self.rejected.connect(self.clean)
    def __init__(self, iface, parent=None):
        """Constructor."""
        super(DrainageChannelBuilderDialog, self).__init__(parent)
        # Set up the user interface from Designer.
        # After setupUI you can access any designer object by doing
        # self.<objectname>, and you can use autoconnect slots - see
        # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
        # #widgets-and-dialogs-with-auto-connect
        self.iface = iface
        self.setupUi(self)

        self.resWarning = False

        self.btnOk = self.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        self.btnOk.setText(self.tr("Run 2D"))
        self.btnClose = self.buttonBox.button(QtGui.QDialogButtonBox.Close)

        self.cbDEM.currentIndexChanged.connect(self.updateRasterRes)
        self.cbDEM.currentIndexChanged.connect(self.checkLayerExtents)
        self.cbCL.currentIndexChanged.connect(self.checkLayerExtents)
        self.spinElevStart.valueChanged.connect(self.calcDepth)
        self.spinElevEnd.valueChanged.connect(self.calcDepth)
        self.spinRightSideSlope.valueChanged.connect(self.updateMaxBankWidth)
        self.spinLeftSideSlope.valueChanged.connect(self.updateMaxBankWidth)
        self.spinWidth.valueChanged.connect(self.checkRes)
        self.spinRes.valueChanged.connect(self.checkRes)
        self.browseBtn.clicked.connect(self.writeDirName)
        self.btn1Dsave.clicked.connect(self.writeOut1Dresults)

        # add matplotlib figure to dialog
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)
        self.figure.subplots_adjust(left=.1,
                                    bottom=0.1,
                                    right=.95,
                                    top=.9,
                                    wspace=None,
                                    hspace=.2)
        self.canvas = FigureCanvas(self.figure)

        self.widgetPlotToolbar = NavigationToolbar(self.canvas,
                                                   self.widgetPlot)
        lstActions = self.widgetPlotToolbar.actions()
        self.widgetPlotToolbar.removeAction(lstActions[7])
        self.gPlot.addWidget(self.canvas)
        self.gPlot.addWidget(self.widgetPlotToolbar)
        self.figure.patch.set_visible(False)

        # and configure matplotlib params
        rcParams["font.serif"] = "Verdana, Arial, Liberation Serif"
        rcParams["font.sans-serif"] = "Tahoma, Arial, Liberation Sans"
        rcParams["font.cursive"] = "Courier New, Arial, Liberation Sans"
        rcParams["font.fantasy"] = "Comic Sans MS, Arial, Liberation Sans"
        rcParams["font.monospace"] = "Courier New, Liberation Mono"

        self.manageGui()
Ejemplo n.º 53
0
 def __init__(self):
     super(MPLPlotWidget, self).__init__()
     layout = QtGui.QVBoxLayout(self)
     fig = Figure()
     self.axes = fig.add_subplot(111)
     self.axes.hold(False)
     self.canvas = FigureCanvasQTAgg(fig)
     self.navbar = NavigationToolbar2QTAgg(self.canvas, self)
     layout.addWidget(self.canvas)
     layout.addWidget(self.navbar)
 def __init__(self, parent=None):
     super(PlotWidget, self).__init__(parent)
     # create widgets
     self.canvas = PlotCanvas()
     self.toolbar = NavigationToolbar(self.canvas, self.canvas)
     self.toolbar.setSizePolicy(QSizePolicy.Preferred,
                                QSizePolicy.Preferred)
     vbox = QVBoxLayout()
     vbox.addWidget(self.toolbar)
     vbox.addWidget(self.canvas)
     self.setLayout(vbox)
Ejemplo n.º 55
0
 def _create_canvas(self, parent):
     """ Create the MPL canvas. """
     # matplotlib commands to create a canvas
     frame = QtGui.QWidget()
     mpl_canvas = FigureCanvas(self.value)
     mpl_canvas.setParent(frame)
     mpl_toolbar = NavigationToolbar2QTAgg(mpl_canvas, frame)
     vbox = QtGui.QVBoxLayout()
     vbox.addWidget(mpl_canvas)
     vbox.addWidget(mpl_toolbar)
     frame.setLayout(vbox)
     return frame
Ejemplo n.º 56
0
    def __init__(self, parent=None, dpi=100, size=(5, 4)):
        """ Class initialiser """

        self.dpi = dpi
        self.figure = Figure(dpi=self.dpi)
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setParent(parent)

        # Create the navigation toolbar, tied to the canvas
        self.toolbar = NavigationToolbar(self.canvas, parent)
        self.canvas.show()
        self.toolbar.show()